• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

MySql help needs

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.io.*;
import java.sql.*;
import org.gjt.mm.mysql.*;
public class MySqlTest{
Connection DBConn;
ResultSet rs;
Statement stmt;
String dsn;
String query;
public MySqlTest(){
try{
Class.forName("org.gjt.mm.mysql.Driver");
}
catch(ClassNotFoundException ce) {
ce.printStackTrace();
}
}
public static void main(String args[]) {
MySqlTest mst=new MySqlTest();
}
}

Compiles OK, but when running, it gives :
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
����
����

Plesae help me.
Regards
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
We can walk to school together. And we can both read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic