tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Ryder" <sry...@jsrsys.com>
Subject Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
Date Mon, 25 Jan 2010 16:16:27 GMT
When I remove the factory line I now get:  Cannot create resource instance
2010-01-25 15:56:06:*WARNING*Connection to jdbc/MySql:: connect Other 
exception: Cannot create resource instance
2010-01-25 15:56:06:Driver=com.mysql.jdbc.Driver

The libraries are all in common\lib.  The ones I have added since the 5.5 
install are:
jsrweb (my Java code), mysql-connector-java-5.0.8-bin.jar,
naming-common.jar, naming-java.jar, mail.jar, and activation.jar.

I picked 5.5 because it is not getting active develpment, yet supports Java 
1.5, and has all the features I need hoping to minimize incompatabilities.

My Java "connect" code reads:   (indentation was lost when I copied)
private void connect(String dbName)

{

lastException = "OK";

try

{

// Class.forName("org.gjt.mm.mysql.Driver");  <---I changed this last night 
hoping to fix problem.

sysout.display("Driver=com.mysql.jdbc.Driver");

Class.forName("com.mysql.jdbc.Driver");

}

catch (Exception E) {lastException=" Unable to load driver"; 
E.printStackTrace();

sysout.display(lastException);}


try

{

sql = "Connection to jdbc/MySql:";

Context myContext = new InitialContext();

Context envContext = (Context)myContext.lookup("java:comp/env");

javax.sql.DataSource ds = 
(javax.sql.DataSource)envContext.lookup("jdbc/MySql");

conn = ds.getConnection();

stmt = conn.createStatement();

sql = "USE "+ dbName; // attempt to mymic jdbcConnect set for dbName!

stmt.execute(sql);

sysout.display("**"+sql + ": connection to jdbc/MySql established.");

}

catch (SQLException E)

{ lastException="*WARNING*"+sql+ ": connect SQL exception: "

+ E.getMessage();

sysout.display(lastException);

//System.exit(4);

}

catch(Exception eOther)

{ lastException="*WARNING*"+sql+ ": connect Other exception: "

+ eOther.getMessage();

sysout.display(lastException);

//System.exit(4);

}

}



----- Original Message ----- 
From: "Caldarale, Charles R" <Chuck.Caldarale@unisys.com>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Monday, January 25, 2010 8:52 AM
Subject: RE: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to 
javax.sql.DataSource


>> From: Steve Ryder [mailto:sryder@jsrsys.com]
>> Subject: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to
>> javax.sql.DataSource
>>
>> <Resource name="jdbc/MySql" auth="Container"
>> type="javax.sql.Datasource"
>> factory="org.apache.commons.dbcp.BasicDataSourceFactory"
>
> The specified factory is for the standard Apache commons DBCP, not the one 
> bundled with Tomcat.  You might try removing it and let the Tomcat DBCP 
> factory do its thing.
>
>> My jdbc driver jar is: mysql-connector-java-5.0.8-bin.jar
>
> Where is the JDBC jar located?
>
> Since you're upgrading, why not upgrade to 6.0.x?  (5.5 is not getting 
> much in the way of active development these days.)
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
> MATERIAL and is thus for use only by the intended recipient. If you 
> received this in error, please contact the sender and delete the e-mail 
> and its attachments from all computers.
>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message