Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Problem in using DataSource

  Asked By: Jody    Date: Oct 01    Category: Java    Views: 559
  

I have a problem in my web application to get DB connection from DataSource when I run project in JBuilder.
See Sections "0 - 4" in below and help me Please !!!!

IDE : JBuilder 2005
DBMS: MySql 3.23.45
Wb Server : tomcat 5.0.27

1.my server8080.xml (server.xml) is incloded these lines :


<Context debug="0" docBase="someAddress" path="/WebModule1" reloadable="true" workDir="someAddress">
<Resourse name="jdbc/HOMEACCOUNT_DBX" type="javax.sql.DataSource" auth="Container"/>
<ResourseParams name="jdbc/HOMEACCOUNT_DBX">
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/HomeAccount_DB</value>
</parameter>
</ResourseParams>
</Context>

2. my web.xml file inclode this lines :

<resource-ref>
<res-ref-name>jdbc/HOMEACCOUNT_DBX</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

3. my code is :

Context ctx = new InitialContext();
datasource = (DataSource) ctx.lookup("java:comp/env/"+dataSourceJNDIName);
....
try {
return datasource.getConnection(); /*this throws exception*/
}catch (Exception e){

}
4. the exeption and its message are :

org.apache.commons.dbcp.SQLNestedException:
Cannot create JDBC driver of class '' for connect URL 'null'

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Randall Franklin     Answered On: Oct 01

Have u put JAR of db driver in your classpath?

 
Answer #2    Answered By: Josie Roberts     Answered On: Oct 01

Seems the jdbc driver is not loaded for pooled connection, hence it is giving an error while intializing the apache connection  pool. Make sure you have all the required jar files (including the ones supplied with MySQL database containing the jdbc drivers) in the “/WEB-INF/lib” directory of your application  if it is an application level pool or in the web  server’s “lib” directory if you are creating server level connection pool (which seems you current option). I hope replacing missing jar files will resolve the issue.

 
Didn't find what you were looking for? Find more on Problem in using DataSource Or get search suggestion and latest updates.




Tagged: