This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes MySql help needs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySql help needs" Watch "MySql help needs" New topic

MySql help needs

fengzixuan zheng
Ranch Hand

Joined: Aug 02, 2001
Posts: 31
I got a problem with my codes when I want to connect to a MySql database.
I have successfullly installed the MySql-4.0.0a-alpha-win, and have the MySql services running.
I copy the the mm.mysql-2.0.4-bin.jar to my JDK root-dir: D:\J2SE; so I set the classpath: "D:\J2SE\src.jar; D:\J2SE\mm.mysql-2.0.4-bin.jar"
My codes :
import java.sql.*;
public class MySqlTest{
Connection DBConn;
ResultSet rs;
Statement stmt;
String dsn;
String query;
public MySqlTest(){
catch(ClassNotFoundException ce) {
public static void main(String args[]) {
MySqlTest mst=new MySqlTest();

Compiles OK, but when running, it gives :

Plesae help me.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
Well your compiler is finding the jar files but the application server isn't. You need to check that it has the jar files in the CLASSPATH. Which server is it?

I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
david long

Joined: Apr 16, 2001
Posts: 8
Hi, fengzixuan zheng
try putting your drive jar file into D:\J2SE
/jre/lib/ext directory, so and you even don't need use classpath for your driver.
if 'ext' folder no exsit, make one.
Consider Paul's rocket mass heater.
subject: MySql help needs
Similar Threads
mysql-jdbc connection problem
Error when using mm.mysql.driver
Connect to MySQL data base
MySQL Driver, Help!
Error when using mm.mysql.driver under Linux