Hi everybody,
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. Did I miss something?
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.
Now for my case I will just implement an extension of ConnectionFactoryDBCPImpl overriding method createConnectionFactory( ... ) and adding the necessary code for loading the necessary properties from our application's config. file, however I guess that this feature may be of use for any OJB user that needs to tweak the JDBC connection.
Thanks in advance for comments/answers, cheers Danilo
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
