• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

connector/J with my SQL.. Driver fails to load!

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I am trying to use connector/J driver for MySQL with Tomcat. I have copied the jar file in to the ~home~/common/lib folder and added the jar file to the classpath. When i try to connect through the following code get "Driver not loaded exception".... please anyone would tell me whats wrong here?
Code in my servlet----->
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)
envCtx.lookup("jdbc/database");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
<----------------------------->
Following is the the entry in my server.xml under <context>

server.xml!
<--------------------------------------------->
<Resource name="jdbc/<database name>" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/<databsename>">
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>root</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/<databasename></value>
</parameter>
<parameter>
<name>maxActive</name>
<value>8</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>4</value>
</parameter>
</ResourceParams>
------------------------------------------>
Bestest of Regards
pervaiz gul
 
reply
    Bookmark Topic Watch Topic
  • New Topic