Uploaded image for project: 'OJB'
  1. OJB
  2. OJB-14

Setting custom JDBC driver tuning options trough jdbc-connection-descriptor

    XMLWordPrintableJSON

Details

    Description

      Copied from Scarab OJB298 (http://issues.apache.org/scarab/issues/id/OJB298).
      Comments from Danilo Tommasina:
      "
      Several database driver need special extra paramters for adding support for special database features like unicode support and tuning options. For this reason in JDBC there is the method 'static Connection getConnection(String url, Properties info)' that allows to feed the driver with several tuning options.

      Looking at the repository documentation I found the <attribute> tag within <jdbc-connection-descriptor> in the repository.xml, I though this was exactly what I needed, however this was not the case, I have no clue what this tag is used for...
      I found no way for setting these options when OJB initialises the db connections.

      After looking at the OJB source code (release 1.0.1), it seems to me that these initialisation method is not supported by OJB.

      The implementation of ConnectionFactoryDBCPImpl uses following code to initialise a DBCP connection factory:

      protected org.apache.commons.dbcp.ConnectionFactory createConnectionFactory(JdbcConnectionDescriptor jcd)

      { return new DriverManagerConnectionFactory(getDbURL(jcd), jcd.getUserName(), jcd.getPassWord()); }

      As you can see this code does not allow to feed the driver with the extra paramaters. DBCP also offers the possibility to init the factory with a Properties object, the method could be written as follows:

      protected org.apache.commons.dbcp.ConnectionFactory createConnectionFactory( JdbcConnectionDescriptor jcd )

      { Properties connProp = new Properties(); // Add user and password connProp.put( "user", jcd.getUserName() ); connProp.put( "password", jcd.getPassWord() ); // Add custom properties connProp.putAll( jcd.getAttributes() ); // METHOD getAttributes() is Missing in JdbcConnectionDescriptor... return new DriverManagerConnectionFactory( getDbURL( jcd ), connProp ); }

      However a method getAttributes() is missing in JdbcConnectionDescriptor (or in its super class) not allowing a generic approach.

      The same problem probably applies to all other ConnectionFactory implementations.

      Note: In MySQL it is possible to set these parameters in the connection URL, other databases do not support this approach.
      "

      Attachments

        Issue Links

          Activity

            People

              mkalen Karl Martin Kalen
              mkalen Karl Martin Kalen
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: