File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "Java 5 EE to MySQL" Watch "Java 5 EE to MySQL" New topic

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

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,

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...
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

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] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Java 5 EE to MySQL
It's not a secret anymore!