Changeset 7521


Ignore:
Timestamp:
Nov 6, 2018, 9:00:49 AM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2130: Upgrade 3-rd party libraries

Removed the need for a db.driver setting in base.config since the driver can be automatically loaded from the db.url setting (using DriverManagager.getDriver(url)).

Location:
trunk
Files:
11 edited

Legend:

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

    r7519 r7521  
    2929# -----
    3030db.dialect          = org.hibernate.dialect.MySQL5InnoDBDialect
    31 db.driver           = com.mysql.cj.jdbc.Driver
    3231db.url              = jdbc:mysql://localhost/base2?characterEncoding=UTF-8&useCursorFetch=true&defaultFetchSize=100&useServerPrepStmts=true
    3332db.dynamic.catalog  = base2dynamic
     
    3938# --------
    4039#db.dialect          = org.hibernate.dialect.PostgreSQL9Dialect
    41 #db.driver           = org.postgresql.Driver
    4240#db.url              = jdbc:postgresql:base2
    4341#db.dynamic.schema   = dynamic
  • trunk/doc/src/docbook/admin/installation.xml

    r7520 r7521  
    5656      </para>
    5757
    58       <bridgehead>New JDBC driver for MySQL</bridgehead>
     58      <bridgehead>The db.driver setting is no longer used</bridgehead>
    5959      <para>
    60         If you are using MySQL it is recommended that you change the
    61         <constant>db.driver</constant> setting in the <filename>base.config</filename>
    62         file to <constant>com.mysql.cj.jdbc.Driver</constant>.
     60        The JDBC driver to use is now found automatically based on
     61        the <constant>db.url</constant> setting in the <filename>base.config</filename>
     62        file. The <constant>db.driver</constant> setting can be removed.
    6363      </para>
    6464    </important>
  • trunk/doc/src/docbook/appendix/base.config.xml

    r7412 r7521  
    4040  <itemizedlist>
    4141    <listitem>
    42       <property>db.dialect</property>, <property>db.driver</property>,
     42      <property>db.dialect</property>,
    4343      <property>db.url</property>, <property>db.username</property>,
    4444      <property>db.password</property>:
     
    8181          </itemizedlist>
    8282          Other dialects may work but are not supported.
    83         </para>
    84       </listitem>
    85     </varlistentry>
    86    
    87     <varlistentry>
    88       <term><property>db.driver</property></term>
    89       <listitem>
    90         <para>
    91           The JDBC driver to use when connecting to the database. Use:
    92           <itemizedlist>
    93           <listitem>
    94             <userinput>com.mysql.jdbc.Driver</userinput>
    95             for MySQL
    96           </listitem>
    97           <listitem>
    98             <userinput>org.postgresql.Driver</userinput>
    99             for PostgreSQL
    100           </listitem>
    101           </itemizedlist>
    102           Other JDBC drivers may work but are not supported.
    10383        </para>
    10484      </listitem>
  • trunk/doc/src/docbook/appendix/update_warnings.xml

    r7520 r7521  
    3939    <title>BASE 3.14</title>
    4040 
    41     <bridgehead>New JDBC driver for MySQL</bridgehead>
    42     <para>
    43       If you are using MySQL it is recommended that you change the
    44       <constant>db.driver</constant> setting in the <filename>base.config</filename>
    45       file to <constant>com.mysql.cj.jdbc.Driver</constant>.
     41    <bridgehead>The db.driver setting is no longer used</bridgehead>
     42    <para>
     43      The JDBC driver to use is now found automatically based on
     44      the <constant>db.url</constant> setting in the <filename>base.config</filename>
     45      file. The <constant>db.driver</constant> setting can be removed.
    4646    </para>
    4747   
  • trunk/src/core/net/sf/basedb/core/Application.java

    r7513 r7521  
    478478     
    479479      log.info("db.dialect = " + Config.getString("db.dialect"));
    480       log.info("db.driver = " + Config.getString("db.driver"));
    481480      log.info("db.url = " + Config.getString("db.url"));
    482481      log.info("db.username = " + Config.getString("db.username"));
  • trunk/src/core/net/sf/basedb/core/HibernateUtil.java

    r7519 r7521  
    291291    Properties baseConfig = new Properties();
    292292    baseConfig.setProperty("hibernate.dialect", dialect);
    293     baseConfig.setProperty("hibernate.connection.driver_class", Config.getString("db.driver", ""));
    294293    baseConfig.setProperty("hibernate.connection.url", Config.getString("db.url", ""));
    295294    baseConfig.setProperty("hibernate.connection.username", Config.getString("db.username", ""));
  • trunk/src/core/net/sf/basedb/core/ServiceSessionControl.java

    r7461 r7521  
    521521      {
    522522        registryBuilder.applySetting("hibernate.dialect", Config.getString("db.dialect", ""));
    523         registryBuilder.applySetting("hibernate.connection.driver_class", Config.getString("db.driver", ""));
    524523        if (actualCatalog != null)
    525524        {
  • trunk/src/install/net/sf/basedb/install/InitDB.java

    r7517 r7521  
    2424
    2525import java.sql.Driver;
     26import java.sql.DriverManager;
    2627import java.util.Arrays;
    2728import java.util.List;
     
    3940import net.sf.basedb.util.ConsoleProgressReporter;
    4041import net.sf.basedb.util.ChainedProgressReporter;
    41 import net.sf.basedb.util.ClassUtil;
    4242
    4343/**
     
    198198  }
    199199
    200   private static void showDbInfo(ProgressReporter progress)
     200  static void showDbInfo(ProgressReporter progress)
    201201  {
    202202    final Properties properties = System.getProperties();
    203     final String jdbcDriver = Config.getString("db.driver");
     203    final String dbUrl = Config.getString("db.url");
     204    String driverClass = "unknown class";
    204205    String driverVersion = "unknown version";
    205206    try
    206207    {
    207       final Driver driver = (Driver)ClassUtil.newInstance(Class.forName(jdbcDriver));
     208      final Driver driver = DriverManager.getDriver(dbUrl);
     209      driverClass = driver.getClass().getName();
    208210      driverVersion = "version " + driver.getMajorVersion() + "." + driver.getMinorVersion();
    209211    }
     
    214216      "--System information-----------------------------\n" +
    215217      "BASE     : " + Version.getVersion() + "\n" +
    216       "Database : " + Config.getString("db.url") + "\n" +
     218      "Database : " + dbUrl + "\n" +
    217219      "Dialect  : " + Config.getString("db.dialect") + "\n" +
    218       "JDBC     : " + jdbcDriver + "; " + driverVersion + "\n" +
     220      "JDBC     : " + driverClass + "; " + driverVersion + "\n" +
    219221      "Java     : " + properties.getProperty("java.runtime.name") + "; " +
    220222        properties.getProperty("java.runtime.version") + "; " +
  • trunk/src/install/net/sf/basedb/install/OneTimeFix.java

    r7517 r7521  
    2525import java.sql.Connection;
    2626import java.sql.DatabaseMetaData;
    27 import java.sql.Driver;
    2827import java.sql.DriverManager;
    2928import java.sql.SQLException;
    30 import java.util.Properties;
    31 
    32 
    33 
    34 
    35 
    3629
    3730import net.sf.basedb.core.Application;
    3831import net.sf.basedb.core.Config;
    39 import net.sf.basedb.core.ProgressReporter;
    4032import net.sf.basedb.core.SessionControl;
    4133import net.sf.basedb.core.Update;
    4234import net.sf.basedb.core.authentication.LoginRequest;
    43 import net.sf.basedb.util.ClassUtil;
    4435import net.sf.basedb.util.ConsoleProgressReporter;
    4536
     
    7970        System.out.println(msg);
    8071        waitForEnter();
    81         showDbInfo(null);
     72        InitDB.showDbInfo(null);
    8273        System.out.println("Starting BASE. Please wait...");
    8374        Application.start(false);
     
    10394        System.out.println(msg);
    10495        waitForEnter();
    105         showDbInfo(null);
     96        InitDB.showDbInfo(null);
    10697        System.out.println("Starting BASE. Please wait...");
    10798        Application.start(false);
     
    136127  }
    137128
    138   private static void showDbInfo(ProgressReporter progress)
    139   {
    140     final Properties properties = System.getProperties();
    141     final String jdbcDriver = Config.getString("db.driver");
    142     String driverVersion = "unknown version";
    143     try
    144     {
    145       final Driver driver = (Driver)ClassUtil.newInstance(Class.forName(jdbcDriver));
    146       driverVersion = "version " + driver.getMajorVersion() + "." + driver.getMinorVersion();
    147     }
    148     catch (Throwable t)
    149     {}
    150    
    151     String message =
    152       "--System information-----------------------------\n" +
    153       "BASE     : " + Application.getMajorVersion() + "." +
    154         Application.getMinorVersion() + "." +
    155         Application.getMaintenanceVersion() + "\n" +
    156       "Database : " + Config.getString("db.url") + "\n" +
    157       "Dialect  : " + Config.getString("db.dialect") + "\n" +
    158       "JDBC     : " + jdbcDriver + "; " + driverVersion + "\n" +
    159       "Java     : " + properties.getProperty("java.runtime.name") + "; " +
    160         properties.getProperty("java.runtime.version") + "; " +
    161         properties.getProperty("java.vendor") + "\n" +
    162       "OS       : " + properties.getProperty("os.name") +"; " +
    163         properties.getProperty("os.arch") + "; " +
    164         properties.getProperty("os.version") +"\n" +
    165       "-------------------------------------------------";
    166     if (progress != null)
    167     {
    168       progress.display(0, message);
    169     }
    170     else
    171     {
    172       System.out.println(message);
    173     }
    174   }
    175  
    176129  public static String getOption(String[] args, String option, String defaultValue)
    177130  {
  • trunk/src/test/TestUtil.java

    r7517 r7521  
    2929import net.sf.basedb.core.Version;
    3030import net.sf.basedb.core.authentication.LoginRequest;
    31 import net.sf.basedb.util.ClassUtil;
    3231
    3332import java.io.File;
     
    3736import java.sql.DatabaseMetaData;
    3837import java.sql.Driver;
     38import java.sql.DriverManager;
    3939import java.util.Properties;
    4040
     
    263263  {
    264264    final Properties properties = System.getProperties();
    265     final String jdbcDriver = Config.getString("db.driver");
     265    final String dbUrl = Config.getString("db.url");
     266    String driverClass = "unknown class";
    266267    String driverVersion = "unknown version";
    267268    String database = "Unknown database";
    268     try
    269     {
    270       final Driver driver = (Driver)ClassUtil.newInstance(Class.forName(jdbcDriver));
     269   
     270    try
     271    {
     272      final Driver driver = DriverManager.getDriver(dbUrl);
     273      driverClass = driver.getClass().getName();
    271274      driverVersion = "version " + driver.getMajorVersion() + "." + driver.getMinorVersion();
    272275      Properties p = new Properties();
    273276      p.setProperty("user", Config.getString("db.username"));
    274277      p.setProperty("password", Config.getString("db.password"));
    275       Connection c = driver.connect(Config.getString("db.url"), p);
     278      Connection c = driver.connect(dbUrl, p);
    276279      DatabaseMetaData data = c.getMetaData();
    277280      database = data.getDatabaseProductName() + " " + data.getDatabaseProductVersion();
     
    287290      "Database : " + database + "\n" +
    288291      "Dialect  : " + Config.getString("db.dialect") + "\n" +
    289       "JDBC     : " + jdbcDriver + "; " + driverVersion + "\n" +
    290       "URL      : " + Config.getString("db.url") + "\n" +
     292      "JDBC     : " + driverClass + "; " + driverVersion + "\n" +
     293      "URL      : " + dbUrl + "\n" +
    291294      "Java     : " + properties.getProperty("java.runtime.name") + "; " +
    292295        properties.getProperty("java.runtime.version") + "; " +
  • trunk/src/test/net/sf/basedb/test/TestUtil.java

    r7517 r7521  
    3131import java.sql.DatabaseMetaData;
    3232import java.sql.Driver;
     33import java.sql.DriverManager;
    3334import java.util.Properties;
    3435
     
    3839import net.sf.basedb.core.SessionControl;
    3940import net.sf.basedb.core.authentication.LoginRequest;
    40 import net.sf.basedb.util.ClassUtil;
    4141
    4242/**
     
    236236  {
    237237    final Properties properties = System.getProperties();
    238     final String jdbcDriver = Config.getString("db.driver");
     238    final String dbUrl = Config.getString("db.url");
     239    String driverClass = "unknown class";
    239240    String driverVersion = "unknown version";
    240241    String database = "Unknown database";
    241242    try
    242243    {
    243       final Driver driver = (Driver)ClassUtil.newInstance(Class.forName(jdbcDriver));
     244      final Driver driver = DriverManager.getDriver(dbUrl);
     245      driverClass = driver.getClass().getName();
    244246      driverVersion = "version " + driver.getMajorVersion() + "." + driver.getMinorVersion();
    245247      Properties p = new Properties();
    246248      p.setProperty("user", Config.getString("db.username"));
    247249      p.setProperty("password", Config.getString("db.password"));
    248       Connection c = driver.connect(Config.getString("db.url"), p);
     250      Connection c = driver.connect(dbUrl, p);
    249251      DatabaseMetaData data = c.getMetaData();
    250252      database = data.getDatabaseProductName() + " " + data.getDatabaseProductVersion();
     
    261263      "Database : " + database + "\n" +
    262264      "Dialect  : " + Config.getString("db.dialect") + "\n" +
    263       "JDBC     : " + jdbcDriver + "; " + driverVersion + "\n" +
    264       "URL      : " + Config.getString("db.url") + "\n" +
     265      "JDBC     : " + driverClass + "; " + driverVersion + "\n" +
     266      "URL      : " + dbUrl + "\n" +
    265267      "Java     : " + properties.getProperty("java.runtime.name") + "; " +
    266268        properties.getProperty("java.runtime.version") + "; " +
Note: See TracChangeset for help on using the changeset viewer.