 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
elektrophyte Guest
|
Posted: Sat Jan 29, 2005 6:25 pm Post subject: Tomcat 5.5 JDBC datasource config problem (MySQL) |
|
|
Hi folks. Any help with this problem would be greatly appreciated. I'm
trying to set up Tomcat 5.5 to provide a JNDI DataSource of a MySQL
4.0.22 server on Windows XP. Configuration details are below. When I
step through the code in the debugger, it appears that the DataSource
object is sucessfully created. At least it isn't null. However, when
it gets to the line...
Connection con = dataSource.getConnection();
.... it throws this exception:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC
driver of class '' for connect URL 'null'
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at gov.mtc.webproc.RequestManager.doPost(RequestManager.java:65)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
etc...
------------------------------------------------------------------
Some more details:
- I put the driver (mysql-connector-java-3.1.6-bin.jar) into
TOMCAT_HOME/common/lib/.
- In server.xml, inside <Host name="localhost" ... > ... </Host> I put
this configuration:
<DefaultContext>
<Resource name="jdbc/commutercorpsds" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/commutercorpsds">
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/commuter_corps_signup</value>
</parameter>
<parameter>
<name>username</name>
<value>USERNAME</value>
</parameter>
<parameter>
<name>password</name>
<value>PASSWORD</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30000</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>100</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>15</value>
</parameter>
</ResourceParams>
</DefaultContext>
- In my application's web.xml I put this:
<resource-ref>
<res-ref-name>jdbc/commutercorpsds</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
- In my Java code I put this:
try
{
InitialContext initialContext = new
InitialContext();
DataSource dataSource =
(DataSource) initialContext.lookup
("java:comp/env/jdbc/commutercorpsds");
Connection con = dataSource.getConnection();
Statement stmt = con.createStatement();
....
con.close();
stmt.close();
} catch (NamingException e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
|
|
| Back to top |
|
 |
Andreas Wollschlaeger Guest
|
Posted: Sat Jan 29, 2005 9:51 pm Post subject: Re: Tomcat 5.5 JDBC datasource config problem (MySQL) |
|
|
elektrophyte wrote:
| Quote: | Hi folks. Any help with this problem would be greatly appreciated. I'm
trying to set up Tomcat 5.5 to provide a JNDI DataSource of a MySQL
4.0.22 server on Windows XP. Configuration details are below. When I
step through the code in the debugger, it appears that the DataSource
object is sucessfully created. At least it isn't null. However, when
it gets to the line...
Connection con = dataSource.getConnection();
... it throws this exception:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC
driver of class '' for connect URL 'null'
at
DefaultContext
Resource name="jdbc/commutercorpsds" auth="Container"
type="javax.sql.DataSource"/
ResourceParams name="jdbc/commutercorpsds"
parameter
name>driverClassName</name
value>com.mysql.jdbc.Driver</value
/parameter
parameter
name>url</name
value>jdbc:mysql://localhost:3306/commuter_corps_signup</value
/parameter
parameter
name>username</name
value>USERNAME</value
/parameter
parameter
name>password</name
value>PASSWORD</value
/parameter
parameter
name>maxActive</name
value>20</value
/parameter
parameter
name>maxIdle</name
value>30000</value
/parameter
parameter
name>maxWait</name
value>100</value
/parameter
parameter
name>removeAbandoned</name
value>true</value
/parameter
parameter
name>removeAbandonedTimeout</name
value>15
/parameter
/ResourceParams
/DefaultContext
|
I remember i had this kind of problem with Tomcat 4.0.6 some decade ago
- try moving the configuration of the Datasource from the DefaultContext
to a more specific context. Some neurons say this was a problem with
Tomcat 4, so i'm surprised this still happens with Tomcat 5.5 - as the
DefaultContext is the most natural place. Maybe have a look
jakarta.apache.org, i think it was somewhere in the FAQs.
HTH, though
Andreas
|
|
| Back to top |
|
 |
elektrophyte Guest
|
Posted: Sun Jan 30, 2005 5:30 am Post subject: Re: Tomcat 5.5 JDBC datasource config problem (MySQL) |
|
|
Thanks for the reply. I tried adding the DataSource config to an
application-specific context, but the result was the same.
|
|
| Back to top |
|
 |
Daniel Rohe Guest
|
Posted: Sun Jan 30, 2005 7:41 am Post subject: Re: Tomcat 5.5 JDBC datasource config problem (MySQL) |
|
|
The configuration of a resource has changed from tomcat 5.0 to 5.5, so
please read the docs
greetings
Daniel
"elektrophyte" <elektrophyte (AT) yahoo (DOT) com> schrieb im Newsbeitrag
news:1107023159.408478.121920 (AT) c13g2000cwb (DOT) googlegroups.com...
| Quote: | Hi folks. Any help with this problem would be greatly appreciated. I'm
trying to set up Tomcat 5.5 to provide a JNDI DataSource of a MySQL
4.0.22 server on Windows XP. Configuration details are below. When I
step through the code in the debugger, it appears that the DataSource
object is sucessfully created. At least it isn't null. However, when
it gets to the line...
Connection con = dataSource.getConnection();
... it throws this exception:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC
driver of class '' for connect URL 'null'
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at gov.mtc.webproc.RequestManager.doPost(RequestManager.java:65)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
etc...
------------------------------------------------------------------
Some more details:
- I put the driver (mysql-connector-java-3.1.6-bin.jar) into
TOMCAT_HOME/common/lib/.
- In server.xml, inside <Host name="localhost" ... > ... </Host> I put
this configuration:
DefaultContext
Resource name="jdbc/commutercorpsds" auth="Container"
type="javax.sql.DataSource"/
ResourceParams name="jdbc/commutercorpsds"
parameter
name>driverClassName</name
value>com.mysql.jdbc.Driver</value
/parameter
parameter
name>url</name
value>jdbc:mysql://localhost:3306/commuter_corps_signup</value
/parameter
parameter
name>username</name
value>USERNAME</value
/parameter
parameter
name>password</name
value>PASSWORD</value
/parameter
parameter
name>maxActive</name
value>20</value
/parameter
parameter
name>maxIdle</name
value>30000</value
/parameter
parameter
name>maxWait</name
value>100</value
/parameter
parameter
name>removeAbandoned</name
value>true</value
/parameter
parameter
name>removeAbandonedTimeout</name
value>15</value
/parameter
/ResourceParams
/DefaultContext
- In my application's web.xml I put this:
resource-ref
res-ref-name>jdbc/commutercorpsds</res-ref-name
res-type>javax.sql.DataSource</res-type
res-auth>Container
/resource-ref
- In my Java code I put this:
try
{
InitialContext initialContext = new
InitialContext();
DataSource dataSource =
(DataSource) initialContext.lookup
("java:comp/env/jdbc/commutercorpsds");
Connection con = dataSource.getConnection();
Statement stmt = con.createStatement();
...
con.close();
stmt.close();
} catch (NamingException e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|