Hi all,
I'm writing a standard application accessing DB2. I want to use DataSource to get database connection in my program. The following is my code:
import com.ibm.websphere.advanced.cm.factory.DataSourceFactory;
import ...
public class
Test {
...
public DataSource getDataSource() {
DataSource ds = null;
try {
Properties props = new Properties();
props.setProperty(DataSourceFactory.NAME, "Test");
props.setProperty(DataSourceFactory.DATASOURCE_CLASS_NAME, "COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource");
props.setProperty(DataSourceFactory.DESCRIPTION, "Description");
props.setProperty(DataSourceFactory.USER, "db2admin");
props.setProperty(DataSourceFactory.PASSWORD, "password");
props.setProperty("databaseName", "sample");
ds = DataSourceFactory.getDataSource(props);
return ds;
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
The username and password are both correct. I compile my code with some websphere v4.0 libraries successfully, such as $WS_HOME/lib/ns.jar, $WS_HOME/lib/cm.jar, $WS_HOME/lib/iworb.jar, $WS_HOME/lib/j2ee.jar and db2java.zip. But an exception are thrown:
com.ibm.ejs.jts.jts.CurrentSet$InitializationError: not initialized
at com.ibm.ejs.jts.jts.CurrentSet.self(CurrentSet.java:218)
at com.ibm.ejs.jts.jts.CurrentSet.get_control(CurrentSet.java:265)
at com.ibm.ejs.jts.jts.Current.get_control(Current.java:72)
at com.ibm.ejs.util.tran.Util.getCoordinator(Util.java:13)
at com.ibm.ejs.cm.pool.ConnectionPool.allocateConnection(ConnectionPool.java:686)
at com.ibm.ejs.cm.pool.ConnectionPool.getConnection(ConnectionPool.java:312)
at com.ibm.ejs.cm.DataSourceImpl$1.run(DataSourceImpl.java:129)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.ejs.cm.DataSourceImpl.getConnection(DataSourceImpl.java:127)
at ...
Could anyone help me to solve the problem? You could respond it in forum or send email to
liming@cn.ibm.com. Your any advice will be appreciated. Thank you in advance.