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
[EMAIL PROTECTED]
920-568-8379


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to