File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Error when Creating DataSource by java Code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Error when Creating DataSource by java Code" Watch "Error when Creating DataSource by java Code" New topic

Error when Creating DataSource by java Code

Vo Hien

Joined: Mar 27, 2007
Posts: 15
I use java code to create a Datasource as below:

Properties props = new Properties();
props.setProperty("hibernate.connection.driver_class", "net.sourceforge.jtds.jdbc.Driver");
props.setProperty("hibernate.connection.url", "jdbc:jtds:sqlserver://hienvo:1433;databaseName=SkillPortMaster");
props.setProperty("hibernate.connection.username", "sa");
props.setProperty("hibernate.connection.password", "VoHi!");
props.setProperty("hibernate.connection.pool_size", "2");

DataSource myDataSource = BasicDataSourceFactory.createDataSource(props);

where BasicDataSourceFactory is the class that I import from
import org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory; (naming-factory-dbcp.jar)

But I get an error as below:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(

Do you have any idea for this error ?
I agree. Here's the link:
subject: Error when Creating DataSource by java Code
It's not a secret anymore!