I'm working on adding database support for the recently open-sourced SapDB,
http://www.sapdb.org.  SapDB allows a session to login in different database
modes, Oracle, DB2, Internal, etc..  The problem with that is the DB adapter
must know which mode the connection was made.  So,

database.default.url =
jdbc:sapdb://HOSTNAME/DATABASE?sqlmode=oracle&autocommit=on
database.default.driver = com.sap.dbtech.jdbc.DriverSapDB
database.default.username = USERNAME
database.default.password = PASSWORD

database.adaptor=DBSapDB
database.adaptor.DBSapDB=com.sap.dbtech.jdbc.DriverSapDB

As you can see, any property that is not username and password, must be
added to the url.  So, if I want all the properties that were used on the
url, I must obviously parse them out.  So the proposal,

JDBC 2.0 specifies the getConnection method as getConnection(url,
java.util.Properties).  Any method that has getConnection(url, username,
password), will simply create the getConnection(url, java.util.Properties).
What if I add methods like;

public DBConnection getConnection(String driver, String url,
java.util.Properties info) {...}

And change methods like;

public DBConnection getConnection(String driver, String url, String
username, String password)
{
     java.util.Properties info = new java.util.Properties();

     info.setProperty("user",username);
     info.setProperty("password",password);

     return getConnection(driver, url, info);
}

The the reading of the property file will create a java.util.Properties
object.  Then you wouldn't have to use the url line for all properties of
the jdbc driver.  And it would make getting those properties much easier.

database.default.url = jdbc:sapdb://HOSTNAME/DATABASE
database.default.driver = com.sap.dbtech.jdbc.DriverSapDB
database.default.username = USERNAME
database.default.password = PASSWORD
database.default.sqlmode = oracle
database.default.autocommit = on

Dave Polito

Reply via email to