Changeset 7519


Ignore:
Timestamp:
Nov 5, 2018, 3:01:50 PM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2130: Upgrade 3-rd party libraries

Updates to make sure that the current catalog and schema is used instead of null. The nullCatalogMeansCurrent=true should no longer be needed in the MySQL connection string.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/config/dist/base.config

    r7518 r7519  
    3030db.dialect          = org.hibernate.dialect.MySQL5InnoDBDialect
    3131db.driver           = com.mysql.cj.jdbc.Driver
    32 db.url              = jdbc:mysql://localhost/base2?characterEncoding=UTF-8&useCursorFetch=true&defaultFetchSize=100&useServerPrepStmts=true&nullCatalogMeansCurrent=true
     32db.url              = jdbc:mysql://localhost/base2?characterEncoding=UTF-8&useCursorFetch=true&defaultFetchSize=100&useServerPrepStmts=true
    3333db.dynamic.catalog  = base2dynamic
    3434db.queries          = /mysql-queries.xml
  • trunk/src/core/net/sf/basedb/core/HibernateUtil.java

    r7496 r7519  
    804804              boolean isEmpty = true;
    805805              DatabaseMetaData metaData = connection.getMetaData();
     806              String catalog = connection.getCatalog();
     807              String schema = connection.getSchema();
    806808              Iterator<PersistentClass> classes = metadata.getEntityBindings().iterator();
    807809              while (classes.hasNext() && isEmpty)
     
    809811                PersistentClass pClass = classes.next();
    810812                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" } );
    812814                if (tables.next())
    813815                {
     
    23692371            DatabaseMetaData metaData = null;
    23702372            List<Table> tables = new LinkedList<Table>();
     2373            String dynamicCatalog = Application.getDynamicCatalog();
     2374            String dynamicSchema = Application.getDynamicSchema();
    23712375           
    23722376            metaData = connection.getMetaData();
    2373             ResultSet result = metaData.getTables(Application.getDynamicCatalog(),
    2374                 Application.getDynamicSchema(), null, null);
     2377            ResultSet result = metaData.getTables(dynamicCatalog, dynamicSchema, null, null);
    23752378           
    23762379            while (result.next())
     
    24092412              try
    24102413              {
    2411                 tiDb = new TableInfo(table, metaData);
     2414                tiDb = new TableInfo(table, metaData, dynamicCatalog, dynamicSchema);
    24122415              }
    24132416              catch (SQLException ex)
  • trunk/src/core/net/sf/basedb/core/Migration.java

    r7381 r7519  
    310310    ResultWriterFactory rwFactory = new PostgresResultWriterFactory();
    311311
    312     String staticCatalog = null;
    313     String staticSchema = null;
     312    String staticCatalog = connection.getCatalog();
     313    String staticSchema = connection.getSchema();
    314314    String dynamicCatalog = Application.getDynamicCatalog();
    315315    String dynamicSchema = Application.getDynamicSchema();
    316    
    317     if (engine instanceof PostgresDbEngine)
    318     {
    319       staticSchema = "public";
    320     }
    321316
    322317    // Load information about all tables in the static and dynamic databases
     
    339334    for (Table table : staticTables)
    340335    {
    341       TableInfo info = new TableInfo(table, metaData);
     336      TableInfo info = new TableInfo(table, metaData, staticCatalog, staticSchema);
    342337      long approxRows = info.getRowCount(engine, connection, true);
    343338      approxTotalRows += approxRows;
     
    352347    for (Table table : dynamicTables)
    353348    {
    354       TableInfo info = new TableInfo(table, metaData);
     349      TableInfo info = new TableInfo(table, metaData, dynamicCatalog, dynamicSchema);
    355350      long approxRows = info.getRowCount(engine, connection, true);
    356351      approxTotalRows += approxRows;
     
    530525    final int TICK_INTERVAL = 1000;
    531526    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);
    533531    progress.display(0, staticTables.size() + " tables in static database");
    534532   
     
    544542        nextTick = System.currentTimeMillis()+TICK_INTERVAL;
    545543      }
    546       TableInfo info = new TableInfo(table, metaData);
     544      TableInfo info = new TableInfo(table, metaData, staticCatalog, staticSchema);
    547545      // Check that data files exists
    548546      File importFile = getDataFile(info);
     
    692690
    693691    // 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();
    696694    for (File dynamicDataFile : dynamicDataFiles)
    697695    {
     
    735733     
    736734      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);
    740736
    741737      File columnsFile = new File(directory, dynamicDataFile.getName().replaceFirst("\\.data(\\.gz)?", ".columns"));
  • trunk/src/core/net/sf/basedb/core/dbengine/TableInfo.java

    r7263 r7519  
    7979  {
    8080    List<Table> tables = new LinkedList<Table>();
     81    if (catalog == null) catalog = metaData.getConnection().getCatalog();
     82    if (schema == null) schema = metaData.getConnection().getSchema();
    8183    ResultSet result = metaData.getTables(catalog, schema, null, new String[] { "TABLE" });
    8284    while (result.next())
     
    122124    @param metaData The JDBC metadata connected to the current database
    123125    @throws SQLException If there is an error
    124   */
     126    @deprecated In 3.14, use {@link #TableInfo(Table, DatabaseMetaData, String, String)} instead
     127  */
     128  @Deprecated
    125129  public TableInfo(Table table, DatabaseMetaData metaData)
    126130      throws SQLException
     
    146150    String catalog = table.getCatalog();
    147151    if (catalog == null) catalog = defaultCatalog;
     152    if (catalog == null) catalog = metaData.getConnection().getCatalog();
    148153    String schema = table.getSchema();
    149154    if (schema == null) schema = defaultSchema;
     155    if (schema == null) schema = metaData.getConnection().getSchema();
    150156   
    151157    ResultSet tables = metaData.getTables(catalog, schema, table.getName(), null);
  • trunk/src/core/net/sf/basedb/core/hibernate/DbIndexWork.java

    r7381 r7519  
    102102    Iterator<Table> tables = metadata.collectTableMappings().iterator();
    103103   
    104     String defaultCatalog = null;
    105     String defaultSchema = null;
     104    String defaultCatalog = connection.getCatalog();
     105    String defaultSchema = connection.getSchema();
    106106    Namespace defaultNs = metadata.getDatabase().getDefaultNamespace();
    107107    if (defaultNs != null)
  • trunk/src/core/net/sf/basedb/core/hibernate/SchemaGenerator.java

    r7461 r7519  
    164164        {
    165165          Table table = tables.next();
    166           TableInfo jdbcTableInfo = new TableInfo(table, jdbcMetaData);
     166          TableInfo jdbcTableInfo = new TableInfo(table, jdbcMetaData, connection.getCatalog(), connection.getSchema());
    167167         
    168168          log.debug("Table: " + table + (jdbcTableInfo.existsInDb() ? " EXISTS" : "NOT FOUND"));
  • trunk/src/core/net/sf/basedb/core/hibernate/TableExistsWork.java

    r6468 r7519  
    7272    {
    7373      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);
    7577      hasTable = tables.next();
    7678    }
  • trunk/src/core/net/sf/basedb/core/hibernate/TableInfoWork.java

    r6468 r7519  
    6363  {
    6464    DatabaseMetaData metaData = connection.getMetaData();
    65     return new TableInfo(table, metaData);
     65    return new TableInfo(table, metaData, connection.getCatalog(), connection.getSchema());
    6666  }
    6767  // --------------------------
Note: See TracChangeset for help on using the changeset viewer.