You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David McMinn <d_...@yahoo.com> on 2006/03/01 16:30:27 UTC

Re: first jdbc tomcat application

I'm running Tomcat 5.5 - The mysql port is 3306 - I made that change to the server.xml file 
   
  "jdbc:mysql://localhost:3306/everycitizen
   
  Still get the same result - page not found or 
  ...."Cannot create JDBC driver of class '' for connect URL 'null' ".


Amila Suriarachchi <am...@gmail.com> wrote:
  On 2/26/06, David McMinn wrote:
>
> I had not added an error-page tag to the web.xml - The default behavior
> would be a stack trace which would be fine w/ me - In my jsp, I have @ page
> errorPage="errorpg.jsp"......
>
> I don't get a stack trace but I get a page w/ this message...."Cannot
> create JDBC driver of class '' for connect URL 'null' ".
>
>
> Here is my original posting.
>
> I'm stepping through the example Professional Apache Tomcat 5 book by
> Wrox in Chapter 14 - I have set up the mysql database and confirmed it works
> and set up the tomcat server and confirmed that I can see my index.jsppage. When I try to go to
> http://localhost:8070/jsp-examples/wroxjdbc/JDBCTest.jsp
> I get a standard The page cannot be displayed page.
>
> I've included all my steps below. Anyone that can help is most
> appreciated. Thanks in advance.....Dave
>
> Steps I have done
>
> 1) Created a DB called everycitizen and a table called test with a
> column called pk. Created user everyuser w/ a password and granted Select
> privileges to that user.
> 2) Copied the mysql-connector-java-3.1.12-bin.jar into
> $CATALINA_HOME/common/lib.
> 3)Added the following to the $CATALINA_HOME/conf/server.xml just before
> the . Password is blotted out.
>
> 
> 
> > javax.sql.Datasource" name="jdbc/WroxTC5" 
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost/everycitizen"


what is the port u run the mysql server?
the default is 3306

"jdbc:mysql://localhost:3306/test?autoReconnect=true"

username="everyuser" password="everypass" maxActive="20" maxIdle="30000"
> maxWait="100"/>
> 
> 4) Added the following to the
> $CATALINA_HOME/webapps/jsp-examples/WEB-INF web.xml file at the bottom
> just before the entry after the last env-entry.
>
> 
> jdbc/WroxTC5
> javax.sql.DataSource
> Container
> 
>
> 5) Added the JDBCTest.jsp file and the errorpg.jsp file to
> $CATALINA_HOME/webapps/jsp-examples/wroxjdbc directory. I created the
> wroxjdbc folder. The JDBC Test is:
>
> 
> 
> >    import="java.sql.*,
>      javax.sql.*,
>      java.io.*,
>      javax.naming.InitialContext,
>      javax.naming.Context" %>
> 
>   JDBC JNDI Resource Test
> >   InitialContext initCtx = new InitialContext();
>   DataSource ds =
> (DataSource)initCtx.lookup("java:comp/env/jdbc/WroxTC5");
>   Connection conn = ds.getConnection();
>   Statement stmt = conn.createStatement();
>   ResultSet rset = stmt.executeQuery("select * from test;");
>   %>
>   
>     
>   XXXX
> 
> >    while (rset.next())
>    {
>    %>
>     
> >    rset.close();
>    stmt.close();
>    conn.close();
>    initCtx.close();
>    %>
> 
> 
>
>
> and the errorpg is:
>
> 
> 
>   An error has occurred 
> 
> 
>
>
> Glen Mazza wrote:
> David McMinn escribió:
> >
> > Unfortunately the logs don't say anything - I just get a page not found.
> If I take that out (and all subsequent jsp) it works fine. So right up to
> that point the jsp page renders fine - When I include that one more line, it
> blows up. I'm still looking but if someone knows please chime in. Thanks,
> >
>
> OK, then, perhaps the error page to forward to *that you have defined in
> the webapp's web.xml file) doesn't exist. TC is trying to forward to
> that error page, can't find it, and hence returns the page not found
> error.
>
> Glen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>


Re: Cannot create JDBC driver of class '' for connect URL 'null'

Posted by David Smith <dn...@cornell.edu>.
I've done several developments with MySQL and Tomcat.  Never defined the
datasource in the <DefaultContext> element so I can't speak to how that
should work.  The error is usually the result of a configuration element
out of place between where the <Resource> element is declared and your
java code.  The <Resource> config looks good though.

My advice is :

- Move this <Resource/> definition to your context's <Context> element
in [tomcat_dir]conf/Catalina/localhost/[webapp_name_here].xml.  If
deploying in a .war file, the file should be named context.xml and
placed in the META-INF directory of your .war file.

- Make sure you have a <resource-ref> section in the web.xml file of
your webapp. 

- This is pretty much a laundry list item, but make sure your mysql.jar
file is in [tomcat_dir]/common/lib.  The jar has to be there to be
picked up by the tomcat container and instantiate a database pool.

If you make these changes, restart tomcat to make sure it catches the
new config.

--David

David McMinn wrote:

>Tomcat Server 5.5.15 - I searched for solutions and most mention a Context element in the server.xml.
>
>I only have a DefaultContext tag within with I have my resouce tag:
>
><DefaultContext>
> <Resource 
>                auth="Container" 
>                driverClassName="com.mysql.jdbc.Driver" 
>                logAbandoned="true" 
>                maxActive="100" 
>                maxIdle="30" 
>                maxWait="10000" 
>                name="jdbc/wroxTC5" 
>                password="everypass" 
>                removeAbandoned="true" 
>                removeAbandonedTimeout="300" 
>                type="javax.sql.DataSource" 
>                url="jdbc:mysql://localhost:3306/everycitizen?autoReconnect=true" 
>                username="everyuser" 
>        />
> </DefaultContext>
>
>The actual failure is on the connection = ds.getConnection(); line in the jsp if that helps any.
>
>SEVERE: Servlet.service() for servlet jsp threw 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 org.apache.jsp.wroxjdbc.JDBCTest_jsp._jspService(org.apache.jsp.wroxjdbc.JDBCTest_jsp:83)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
> at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:831)
> at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
> at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1203)
> at java.lang.Thread.run(Unknown Source)
>Caused by: java.sql.SQLException: No suitable driver
> at java.sql.DriverManager.getDriver(Unknown Source)
> at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
> ... 21 more
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Cannot create JDBC driver of class '' for connect URL 'null'

Posted by Tim Lucia <ti...@yahoo.com>.
Backwards.  See http://www.mysql.com/products/connector/j/

Tim

-----Original Message-----
From: Mike Sabroff [mailto:mike.sabroff@cygnusb2b.com] 
Sent: Wednesday, March 01, 2006 10:43 PM
To: Tomcat Users List
Subject: Re: Cannot create JDBC driver of class '' for connect URL 'null'

Isn't that the old mysql driver?? I thought the new one is:
org.gjt.mm.mysql.Driver
or do I have it backwards?

David McMinn wrote:
>
> Tomcat Server 5.5.15 - I searched for solutions and most mention a 
> Context element in the server.xml.
>
> I only have a DefaultContext tag within with I have my resouce tag:
>
> <DefaultContext>
>  <Resource
>                 auth="Container"
>                 driverClassName="com.mysql.jdbc.Driver"
>                 logAbandoned="true"
>                 maxActive="100"
>                 maxIdle="30"
>                 maxWait="10000"
>                 name="jdbc/wroxTC5"
>                 password="everypass"
>                 removeAbandoned="true"
>                 removeAbandonedTimeout="300"
>                 type="javax.sql.DataSource"
>                 
> url="jdbc:mysql://localhost:3306/everycitizen?autoReconnect=true"
>                 username="everyuser"
>         />
>  </DefaultContext>
>
> The actual failure is on the connection = ds.getConnection(); line in 
> the jsp if that helps any.
>
> SEVERE: Servlet.service() for servlet jsp threw 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.ja
va:540)
>  at 
>
org.apache.jsp.wroxjdbc.JDBCTest_jsp._jspService(org.apache.jsp.wroxjdbc.JDB
CTest_jsp:83)
>  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>  at 
>
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
32)
>  at 
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
>  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>  at 
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:252)
>  at 
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:173)
>  at 
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:213)
>  at 
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:178)
>  at 
>
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:432)
>  at 
>
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126
)
>  at 
>
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105
)
>  at 
>
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:107)
>  at 
>
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>  at 
>
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:
831)
>  at 
>
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(H
ttp11AprProtocol.java:639)
>  at 
> org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1203)
>  at java.lang.Thread.run(Unknown Source)
> Caused by: java.sql.SQLException: No suitable driver
>  at java.sql.DriverManager.getDriver(Unknown Source)
>  at 
>
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource
.java:773)
>  ... 21 more
>

-- 
Mike Sabroff
Web Services Developer
mike.sabroff@cygnusb2b.com
920-568-8379


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Cannot create JDBC driver of class '' for connect URL 'null'

Posted by Mike Sabroff <mi...@cygnusb2b.com>.
Isn't that the old mysql driver?? I thought the new one is:
org.gjt.mm.mysql.Driver
or do I have it backwards?

David McMinn wrote:
>
> Tomcat Server 5.5.15 - I searched for solutions and most mention a 
> Context element in the server.xml.
>
> I only have a DefaultContext tag within with I have my resouce tag:
>
> <DefaultContext>
>  <Resource
>                 auth="Container"
>                 driverClassName="com.mysql.jdbc.Driver"
>                 logAbandoned="true"
>                 maxActive="100"
>                 maxIdle="30"
>                 maxWait="10000"
>                 name="jdbc/wroxTC5"
>                 password="everypass"
>                 removeAbandoned="true"
>                 removeAbandonedTimeout="300"
>                 type="javax.sql.DataSource"
>                 
> url="jdbc:mysql://localhost:3306/everycitizen?autoReconnect=true"
>                 username="everyuser"
>         />
>  </DefaultContext>
>
> The actual failure is on the connection = ds.getConnection(); line in 
> the jsp if that helps any.
>
> SEVERE: Servlet.service() for servlet jsp threw 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 
> org.apache.jsp.wroxjdbc.JDBCTest_jsp._jspService(org.apache.jsp.wroxjdbc.JDBCTest_jsp:83)
>  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>  at 
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
>  at 
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
>  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>  at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
>  at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>  at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>  at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
>  at 
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
>  at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
>  at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>  at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
>  at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>  at 
> org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:831)
>  at 
> org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
>  at 
> org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1203)
>  at java.lang.Thread.run(Unknown Source)
> Caused by: java.sql.SQLException: No suitable driver
>  at java.sql.DriverManager.getDriver(Unknown Source)
>  at 
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
>  ... 21 more
>

-- 
Mike Sabroff
Web Services Developer
mike.sabroff@cygnusb2b.com
920-568-8379


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Cannot create JDBC driver of class '' for connect URL 'null'

Posted by David McMinn <d_...@yahoo.com>.
Tomcat Server 5.5.15 - I searched for solutions and most mention a Context element in the server.xml.

I only have a DefaultContext tag within with I have my resouce tag:

<DefaultContext>
 <Resource 
                auth="Container" 
                driverClassName="com.mysql.jdbc.Driver" 
                logAbandoned="true" 
                maxActive="100" 
                maxIdle="30" 
                maxWait="10000" 
                name="jdbc/wroxTC5" 
                password="everypass" 
                removeAbandoned="true" 
                removeAbandonedTimeout="300" 
                type="javax.sql.DataSource" 
                url="jdbc:mysql://localhost:3306/everycitizen?autoReconnect=true" 
                username="everyuser" 
        />
 </DefaultContext>

The actual failure is on the connection = ds.getConnection(); line in the jsp if that helps any.

SEVERE: Servlet.service() for servlet jsp threw 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 org.apache.jsp.wroxjdbc.JDBCTest_jsp._jspService(org.apache.jsp.wroxjdbc.JDBCTest_jsp:83)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:831)
 at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
 at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1203)
 at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: No suitable driver
 at java.sql.DriverManager.getDriver(Unknown Source)
 at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
 ... 21 more


Re: jdbc tomcat

Posted by David McMinn <d_...@yahoo.com>.
no change - same situation.

Mike Sabroff <mi...@cygnusb2b.com> wrote:  When I do this from a program or bean or servlet, i make the connection 
a true url:

url="jdbc:mysql://localhost:3306/everycitizen?username=everyuser&password=%%%%%"

I dont know if it is different in the server.xml as I have never tried this, but why should it be?

I have been fooled by thinking logically b4 and I know that things are different in different setups, but it's worth a try, huh?

Mike



David McMinn wrote:
> I'm running Tomcat 5.5 and trying to do a very simple jdbc connection a single table. I have set up tomcat to run on port 8070 and the mysql database on the default 3306 port. It's the connection statement in the jsp that is blowing up - If I take that out, it works fine.
> 
> I'm getting page not found or 
> ...."Cannot create JDBC driver of class '' for connect URL 'null' ".
>
>
> 
>> Steps I have done
>>
>> 1) Created a DB called everycitizen and a table called test with a
>> column called pk. Created user everyuser w/ a password and granted Select privileges to that user.
>> 2) Copied the mysql-connector-java-3.1.12-bin.jar into
>> $CATALINA_HOME/common/lib.
>> 3)Added the following to the $CATALINA_HOME/conf/server.xml 
>> 
> 
> 
>>> javax.sql.Datasource" name="jdbc/WroxTC5" 
>>> 
>> driverClassName="com.mysql.jdbc.Driver"
>> url="jdbc:mysql://localhost:3306/everycitizen" username="everyuser" password="%%%%%" maxActive="20" maxIdle="30000"
>> maxWait="100"/>
>>
>> 4) Added the following to the
>> $CATALINA_HOME/webapps/jsp-examples/WEB-INF web.xml file at the bottom
>> just before the entry after the last env-entry.
>>
>>
>> jdbc/WroxTC5
>> javax.sql.DataSource
>> Container
>>
>>
>> 5) Added the JDBCTest.jsp file and the errorpg.jsp file to
>> $CATALINA_HOME/webapps/jsp-examples/wroxjdbc directory. I created the
>> wroxjdbc folder. The JDBC Test is:
>>
>>
>>
>> 
>>> import="java.sql.*,
>>> 
>> javax.sql.*,
>> java.io.*,
>> javax.naming.InitialContext,
>> javax.naming.Context" %>
>>
>> JDBC JNDI Resource Test
>> 
>>> InitialContext initCtx = new InitialContext();
>>> 
>> DataSource ds =
>> (DataSource)initCtx.lookup("java:comp/env/jdbc/WroxTC5");
>> Connection conn = ds.getConnection();
>> Statement stmt = conn.createStatement();
>> ResultSet rset = stmt.executeQuery("select * from test;");
>> %>
>>
>>
>> XXXX
>>
>> 
>>> while (rset.next())
>>> 
>> {
>> %>
>>
>> 
>>> rset.close();
>>> 
>> stmt.close();
>> conn.close();
>> initCtx.close();
>> %>
>> 
>
> 

-- 
Mike Sabroff
Web Services
Developer
mike.sabroff@cygnusb2b.com
920-568-8379


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



Re: jdbc tomcat

Posted by Mike Sabroff <mi...@cygnusb2b.com>.
When I do this from a program or bean or servlet, i make the connection 
a true url:

url="jdbc:mysql://localhost:3306/everycitizen?username=everyuser&password=%%%%%"

I dont know if it is different in the server.xml as I have never tried this, but why should it be?

I have been fooled by thinking logically b4 and I know that things are different in different setups, but it's worth a try, huh?

Mike



David McMinn wrote:
>   I'm running Tomcat 5.5 and trying to do a very simple jdbc connection a single table. I have set up tomcat to run on port 8070 and the mysql database on the default 3306 port. It's the connection statement in the jsp that is blowing up - If I take that out, it works fine.
>    
>   I'm getting page not found or 
> ...."Cannot create JDBC driver of class '' for connect URL 'null' ".
>
>
>   
>> Steps I have done
>>
>> 1) Created a DB called everycitizen and a table called test with a
>> column called pk. Created user everyuser w/ a password and granted Select privileges to that user.
>> 2) Copied the mysql-connector-java-3.1.12-bin.jar into
>> $CATALINA_HOME/common/lib.
>> 3)Added the following to the $CATALINA_HOME/conf/server.xml 
>>     
>   
>   
>>> javax.sql.Datasource" name="jdbc/WroxTC5" 
>>>       
>> driverClassName="com.mysql.jdbc.Driver"
>> url="jdbc:mysql://localhost:3306/everycitizen" username="everyuser" password="%%%%%" maxActive="20" maxIdle="30000"
>> maxWait="100"/>
>>
>> 4) Added the following to the
>> $CATALINA_HOME/webapps/jsp-examples/WEB-INF web.xml file at the bottom
>> just before the entry after the last env-entry.
>>
>>
>> jdbc/WroxTC5
>> javax.sql.DataSource
>> Container
>>
>>
>> 5) Added the JDBCTest.jsp file and the errorpg.jsp file to
>> $CATALINA_HOME/webapps/jsp-examples/wroxjdbc directory. I created the
>> wroxjdbc folder. The JDBC Test is:
>>
>>
>>
>>     
>>> import="java.sql.*,
>>>       
>> javax.sql.*,
>> java.io.*,
>> javax.naming.InitialContext,
>> javax.naming.Context" %>
>>
>> JDBC JNDI Resource Test
>>     
>>> InitialContext initCtx = new InitialContext();
>>>       
>> DataSource ds =
>> (DataSource)initCtx.lookup("java:comp/env/jdbc/WroxTC5");
>> Connection conn = ds.getConnection();
>> Statement stmt = conn.createStatement();
>> ResultSet rset = stmt.executeQuery("select * from test;");
>> %>
>>
>>
>> XXXX
>>
>>     
>>> while (rset.next())
>>>       
>> {
>> %>
>>
>>     
>>> rset.close();
>>>       
>> stmt.close();
>> conn.close();
>> initCtx.close();
>> %>
>>     
>
>   

-- 
Mike Sabroff
Web Services
Developer
mike.sabroff@cygnusb2b.com
920-568-8379


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


jdbc tomcat

Posted by David McMinn <d_...@yahoo.com>.
  I'm running Tomcat 5.5 and trying to do a very simple jdbc connection a single table. I have set up tomcat to run on port 8070 and the mysql database on the default 3306 port. It's the connection statement in the jsp that is blowing up - If I take that out, it works fine.
   
  I'm getting page not found or 
...."Cannot create JDBC driver of class '' for connect URL 'null' ".


> Steps I have done
>
> 1) Created a DB called everycitizen and a table called test with a
> column called pk. Created user everyuser w/ a password and granted Select privileges to that user.
> 2) Copied the mysql-connector-java-3.1.12-bin.jar into
> $CATALINA_HOME/common/lib.
> 3)Added the following to the $CATALINA_HOME/conf/server.xml 
  
> > javax.sql.Datasource" name="jdbc/WroxTC5" 
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost:3306/everycitizen" username="everyuser" password="%%%%%" maxActive="20" maxIdle="30000"
> maxWait="100"/>
> 
> 4) Added the following to the
> $CATALINA_HOME/webapps/jsp-examples/WEB-INF web.xml file at the bottom
> just before the entry after the last env-entry.
>
> 
> jdbc/WroxTC5
> javax.sql.DataSource
> Container
> 
>
> 5) Added the JDBCTest.jsp file and the errorpg.jsp file to
> $CATALINA_HOME/webapps/jsp-examples/wroxjdbc directory. I created the
> wroxjdbc folder. The JDBC Test is:
>
> 
> 
> > import="java.sql.*,
> javax.sql.*,
> java.io.*,
> javax.naming.InitialContext,
> javax.naming.Context" %>
> 
> JDBC JNDI Resource Test
> > InitialContext initCtx = new InitialContext();
> DataSource ds =
> (DataSource)initCtx.lookup("java:comp/env/jdbc/WroxTC5");
> Connection conn = ds.getConnection();
> Statement stmt = conn.createStatement();
> ResultSet rset = stmt.executeQuery("select * from test;");
> %>
> 
> 
> XXXX
> 
> > while (rset.next())
> {
> %>
> 
> > rset.close();
> stmt.close();
> conn.close();
> initCtx.close();
> %>