File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Java 5 EE to MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java 5 EE to MySQL" Watch "Java 5 EE to MySQL" New topic
Author

Java 5 EE to MySQL

Sam Gardner
Ranch Hand

Joined: Oct 02, 2007
Posts: 31
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

Joined: May 31, 2007
Posts: 58
I think you need to have mysql-connector JAR in your build path and in the lib folder of your application in Eclipse


Coming soon... www.javatales.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61772
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java 5 EE to MySQL