Changeset 7519
- Timestamp:
- Nov 5, 2018, 3:01:50 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/config/dist/base.config
r7518 r7519 30 30 db.dialect = org.hibernate.dialect.MySQL5InnoDBDialect 31 31 db.driver = com.mysql.cj.jdbc.Driver 32 db.url = jdbc:mysql://localhost/base2?characterEncoding=UTF-8&useCursorFetch=true&defaultFetchSize=100&useServerPrepStmts=true &nullCatalogMeansCurrent=true32 db.url = jdbc:mysql://localhost/base2?characterEncoding=UTF-8&useCursorFetch=true&defaultFetchSize=100&useServerPrepStmts=true 33 33 db.dynamic.catalog = base2dynamic 34 34 db.queries = /mysql-queries.xml -
trunk/src/core/net/sf/basedb/core/HibernateUtil.java
r7496 r7519 804 804 boolean isEmpty = true; 805 805 DatabaseMetaData metaData = connection.getMetaData(); 806 String catalog = connection.getCatalog(); 807 String schema = connection.getSchema(); 806 808 Iterator<PersistentClass> classes = metadata.getEntityBindings().iterator(); 807 809 while (classes.hasNext() && isEmpty) … … 809 811 PersistentClass pClass = classes.next(); 810 812 Table t = pClass.getTable(); 811 ResultSet tables = metaData.getTables( t.getCatalog(), t.getSchema(), t.getName(), new String[] { "TABLE" } );813 ResultSet tables = metaData.getTables(catalog, schema, t.getName(), new String[] { "TABLE" } ); 812 814 if (tables.next()) 813 815 { … … 2369 2371 DatabaseMetaData metaData = null; 2370 2372 List<Table> tables = new LinkedList<Table>(); 2373 String dynamicCatalog = Application.getDynamicCatalog(); 2374 String dynamicSchema = Application.getDynamicSchema(); 2371 2375 2372 2376 metaData = connection.getMetaData(); 2373 ResultSet result = metaData.getTables(Application.getDynamicCatalog(), 2374 Application.getDynamicSchema(), null, null); 2377 ResultSet result = metaData.getTables(dynamicCatalog, dynamicSchema, null, null); 2375 2378 2376 2379 while (result.next()) … … 2409 2412 try 2410 2413 { 2411 tiDb = new TableInfo(table, metaData );2414 tiDb = new TableInfo(table, metaData, dynamicCatalog, dynamicSchema); 2412 2415 } 2413 2416 catch (SQLException ex) -
trunk/src/core/net/sf/basedb/core/Migration.java
r7381 r7519 310 310 ResultWriterFactory rwFactory = new PostgresResultWriterFactory(); 311 311 312 String staticCatalog = null;313 String staticSchema = null;312 String staticCatalog = connection.getCatalog(); 313 String staticSchema = connection.getSchema(); 314 314 String dynamicCatalog = Application.getDynamicCatalog(); 315 315 String dynamicSchema = Application.getDynamicSchema(); 316 317 if (engine instanceof PostgresDbEngine)318 {319 staticSchema = "public";320 }321 316 322 317 // Load information about all tables in the static and dynamic databases … … 339 334 for (Table table : staticTables) 340 335 { 341 TableInfo info = new TableInfo(table, metaData );336 TableInfo info = new TableInfo(table, metaData, staticCatalog, staticSchema); 342 337 long approxRows = info.getRowCount(engine, connection, true); 343 338 approxTotalRows += approxRows; … … 352 347 for (Table table : dynamicTables) 353 348 { 354 TableInfo info = new TableInfo(table, metaData );349 TableInfo info = new TableInfo(table, metaData, dynamicCatalog, dynamicSchema); 355 350 long approxRows = info.getRowCount(engine, connection, true); 356 351 approxTotalRows += approxRows; … … 530 525 final int TICK_INTERVAL = 1000; 531 526 long nextTick = System.currentTimeMillis() + TICK_INTERVAL; 532 List<Table> staticTables = TableInfo.listTables(metaData, connection.getCatalog(), "public"); 527 528 String staticCatalog = connection.getCatalog(); 529 String staticSchema = connection.getSchema(); 530 List<Table> staticTables = TableInfo.listTables(metaData, staticCatalog, staticSchema); 533 531 progress.display(0, staticTables.size() + " tables in static database"); 534 532 … … 544 542 nextTick = System.currentTimeMillis()+TICK_INTERVAL; 545 543 } 546 TableInfo info = new TableInfo(table, metaData );544 TableInfo info = new TableInfo(table, metaData, staticCatalog, staticSchema); 547 545 // Check that data files exists 548 546 File importFile = getDataFile(info); … … 692 690 693 691 // Import data for each table in the dynamic database 694 String dynamicCatalog = HibernateUtil.quote(Application.getDynamicCatalog());695 String dynamicSchema = HibernateUtil.quote(Application.getDynamicSchema());692 String dynamicCatalog = Application.getDynamicCatalog(); 693 String dynamicSchema = Application.getDynamicSchema(); 696 694 for (File dynamicDataFile : dynamicDataFiles) 697 695 { … … 735 733 736 734 Table dynamicTable = new Table(tableName); 737 dynamicTable.setCatalog(Application.getDynamicCatalog()); 738 dynamicTable.setSchema(Application.getDynamicSchema()); 739 TableInfo table = new TableInfo(dynamicTable, metaData); 735 TableInfo table = new TableInfo(dynamicTable, metaData, dynamicCatalog, dynamicSchema); 740 736 741 737 File columnsFile = new File(directory, dynamicDataFile.getName().replaceFirst("\\.data(\\.gz)?", ".columns")); -
trunk/src/core/net/sf/basedb/core/dbengine/TableInfo.java
r7263 r7519 79 79 { 80 80 List<Table> tables = new LinkedList<Table>(); 81 if (catalog == null) catalog = metaData.getConnection().getCatalog(); 82 if (schema == null) schema = metaData.getConnection().getSchema(); 81 83 ResultSet result = metaData.getTables(catalog, schema, null, new String[] { "TABLE" }); 82 84 while (result.next()) … … 122 124 @param metaData The JDBC metadata connected to the current database 123 125 @throws SQLException If there is an error 124 */ 126 @deprecated In 3.14, use {@link #TableInfo(Table, DatabaseMetaData, String, String)} instead 127 */ 128 @Deprecated 125 129 public TableInfo(Table table, DatabaseMetaData metaData) 126 130 throws SQLException … … 146 150 String catalog = table.getCatalog(); 147 151 if (catalog == null) catalog = defaultCatalog; 152 if (catalog == null) catalog = metaData.getConnection().getCatalog(); 148 153 String schema = table.getSchema(); 149 154 if (schema == null) schema = defaultSchema; 155 if (schema == null) schema = metaData.getConnection().getSchema(); 150 156 151 157 ResultSet tables = metaData.getTables(catalog, schema, table.getName(), null); -
trunk/src/core/net/sf/basedb/core/hibernate/DbIndexWork.java
r7381 r7519 102 102 Iterator<Table> tables = metadata.collectTableMappings().iterator(); 103 103 104 String defaultCatalog = null;105 String defaultSchema = null;104 String defaultCatalog = connection.getCatalog(); 105 String defaultSchema = connection.getSchema(); 106 106 Namespace defaultNs = metadata.getDatabase().getDefaultNamespace(); 107 107 if (defaultNs != null) -
trunk/src/core/net/sf/basedb/core/hibernate/SchemaGenerator.java
r7461 r7519 164 164 { 165 165 Table table = tables.next(); 166 TableInfo jdbcTableInfo = new TableInfo(table, jdbcMetaData );166 TableInfo jdbcTableInfo = new TableInfo(table, jdbcMetaData, connection.getCatalog(), connection.getSchema()); 167 167 168 168 log.debug("Table: " + table + (jdbcTableInfo.existsInDb() ? " EXISTS" : "NOT FOUND")); -
trunk/src/core/net/sf/basedb/core/hibernate/TableExistsWork.java
r6468 r7519 72 72 { 73 73 DatabaseMetaData metaData = connection.getMetaData(); 74 tables = metaData.getTables(catalog, schema, table, null); 74 String cat = catalog == null ? connection.getCatalog() : catalog; 75 String sch = schema == null ? connection.getSchema() : schema; 76 tables = metaData.getTables(cat, sch, table, null); 75 77 hasTable = tables.next(); 76 78 } -
trunk/src/core/net/sf/basedb/core/hibernate/TableInfoWork.java
r6468 r7519 63 63 { 64 64 DatabaseMetaData metaData = connection.getMetaData(); 65 return new TableInfo(table, metaData );65 return new TableInfo(table, metaData, connection.getCatalog(), connection.getSchema()); 66 66 } 67 67 // --------------------------
Note: See TracChangeset
for help on using the changeset viewer.