Class.forName()

greetings,

Hugo

----- Original Message -----
From: "Zumba" <[EMAIL PROTECTED]>
To: <JSP-INTEREST@JAVA.SUN.COM>
Sent: Tuesday, August 16, 2005 5:22 PM
Subject: JDBC Driver, Context & DataSource lookup


> I'm trying to connect to mysql database using InitialContext and
> DataSource lookup but it not works on FreeBSD 5.4 + tomcat 5.5 + jdk
> 1.5.0 + mysql-connector-java.jar (3.1.0) installed from ports. The
> application seems that reads ok the JNDI Resources variables but when I
> invoke dataSource.getConnection() I get the message on SQLException:
> "Cannot create JDBC class for 'com.mysql.jdbc.Driver'. The fact is if I
> use DriverManager.getConnection("jdbc:mysql//localhost/mysql?params")
> without handle mysql-connector-java.jar and your directories it
> (com.mysql.jdbc.Driver) works fine.
>
> ---- META-INF/context.xml:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <Context
> docBase="${catalina.home}/webapps/Grid"
> path="/Grid"
> reloadable="true">
>    <Resource
>     name="jdbc/GridDB"
>     type="javax.sql.DataSource"
>     auth="Container"
>     username="grid"
>     password="abc123456"
>     driverClassName="com.mysql.jdbc.Driver"
>     url="jdbc:mysql://localhost/griddb?autoReconnect=true"/>
> </Context>
>
> ---- the reference on WEB-INF/Web.xml:
> <resource-ref>
>                 <res-ref-name>jdbc/GridDB</res-ref-name>
>                 <res-type>javax.sql.DataSource</res-type>
>                 <res-auth>Container</res-auth>
> </resource-ref>
>
> ---- servlet code:
> Context initialContext = new InitialContext();
> Context env = (Context) initialContext.lookup("java:comp/env");
> DataSource dataSource = (DataSource) env.lookup("jdbc/GridDB");
> connection = dataSource.getConnection();
>
> Thanks,
> Zumba
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
>
> Some relevant archives, FAQs and Forums on JSPs can be found at:
>
>  http://java.sun.com/products/jsp
>  http://archives.java.sun.com/jsp-interest.html
>  http://forums.java.sun.com
>  http://www.jspinsider.com
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to