Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java 5 EE to MySQL

 
Sam Gardner
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys,

I'm working on a project that involves a web client connecting to a fairly small MySQL database that holds the results of surveys. While I'm fairly experienced with Java, I haven't worked with JDBC too much, and I'd like some guidance on an exception I'm getting.

First off, the setup:
1) MySQL 5.0 running on an OSX dual-G5 server.
2) Sun Application Server 9.1 running locally on my computer.
3) Java 5 EE configured with Eclipse 3.3
JDK 1.6.0.2
JRE 1.6.0.2

The problem I'm running into occurs when my program tries to connect to the MySQL database. Heres the relevant code:



and here's the trace log of the exception:



The relevant part of that is the "Database driver not found" part; the null pointer is thrown because the rest of my class tries to use the connection that's obviously not being created correctly.

I know it's possible to get the connection working, as I can connect to the database using the Database Development plugin that came with Eclipse.

Can anyone here walk me through where to paste/stick the Connector/J jar to give my application access? Preferably somewhere inside my actual application's file system to simplify the migration over to an actual server.

Thanks a lot,

Sam
 
Vikrant Sahdev
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to have mysql-connector JAR in your build path and in the lib folder of your application in Eclipse
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64982
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are planning to rely upon container-managed connection pooling (a best practice), the jar file with the driver must be placed where it will be in the classpath of the container as well as the web apps that will use it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic