thedogeater
asked on
getting a start at jdbc mysql
I am useing jdk1.1.8
and mm.mysql.jdbc-1.2c
I want to this code
import java.sql.*;
public class ConnectCoffeesMM {
public static void main(String args[]) {
// The URL that will connect to TECFA's MySQL server
// Syntax: jdbc:TYPE:machine:port/DB_ NAME
String url = "jdbc:mysql://serka.sawbos .jive:3306 /CD";
// INSTALL/load the Driver (Vendor specific Code)
try {
Class.forName("org.gjt.mm. mysql.Driv er");
} catch(java.lang.ClassNotFo undExcepti on e) {
System.err.print("ClassNot FoundExcep tion: ");
System.err.println(e.getMe ssage());
}
try {
Connection con;
Statement stmt;
// Establish Connection to the database at URL with usename and password
con = DriverManager.getConnectio n(url, "root", "*******");
System.out.println ("Hello, Connection to the CD table worked");
con.close();
} catch(SQLException ex) {
System.err.println("==> SQLException: ");
while (ex != null) {
System.out.println("Messag e: " + ex.getMessage ());
System.out.println("SQLSta te: " + ex.getSQLState ());
System.out.println("ErrorC ode: " + ex.getErrorCode ());
ex = ex.getNextException();
System.out.println("");
}
}
}
}
all goes well with javac
but java ConnectCoffeesMM gives me
ClassNotFoundException: org.gjt.mm.mysql.Driver
==> SQLException:
Message: No suitable driver
SQLState: 08001
ErrorCode: 0
So I have not got it my CLASSPATH
but setevn CLASSPATH /usr/local/mm.mysql.jdbc-1 .2c:$CLASS PATH
gets me nothing, now I am told
Can't find class ConnectCoffeesMM
so the $CLASSPATH must be wrong what shoud it be?? I am baffeled
Thanks for any help.
and mm.mysql.jdbc-1.2c
I want to this code
import java.sql.*;
public class ConnectCoffeesMM {
public static void main(String args[]) {
// The URL that will connect to TECFA's MySQL server
// Syntax: jdbc:TYPE:machine:port/DB_
String url = "jdbc:mysql://serka.sawbos
// INSTALL/load the Driver (Vendor specific Code)
try {
Class.forName("org.gjt.mm.
} catch(java.lang.ClassNotFo
System.err.print("ClassNot
System.err.println(e.getMe
}
try {
Connection con;
Statement stmt;
// Establish Connection to the database at URL with usename and password
con = DriverManager.getConnectio
System.out.println ("Hello, Connection to the CD table worked");
con.close();
} catch(SQLException ex) {
System.err.println("==> SQLException: ");
while (ex != null) {
System.out.println("Messag
System.out.println("SQLSta
System.out.println("ErrorC
ex = ex.getNextException();
System.out.println("");
}
}
}
}
all goes well with javac
but java ConnectCoffeesMM gives me
ClassNotFoundException: org.gjt.mm.mysql.Driver
==> SQLException:
Message: No suitable driver
SQLState: 08001
ErrorCode: 0
So I have not got it my CLASSPATH
but setevn CLASSPATH /usr/local/mm.mysql.jdbc-1
gets me nothing, now I am told
Can't find class ConnectCoffeesMM
so the $CLASSPATH must be wrong what shoud it be?? I am baffeled
Thanks for any help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thans for teh responces I got it to work in the end
fmaritato was right about the CLASSPATH
but the one he or she gave did not work
anyhow Iwill give teh points.
fmaritato was right about the CLASSPATH
but the one he or she gave did not work
anyhow Iwill give teh points.
hi thedogeater,
i have same problem as you,
ClassNotFoundException: com/imaginary/sql/msql/Msq lDriver
==> SQLException:
Message: driver not found: jdbc:mysql://www.hketutor.com/hketutor
SQLState: null
ErrorCode: 0
how can you solve your problem?
can you explain it in details to me?
i can give you 100 points.
i have same problem as you,
ClassNotFoundException: com/imaginary/sql/msql/Msq
==> SQLException:
Message: driver not found: jdbc:mysql://www.hketutor.com/hketutor
SQLState: null
ErrorCode: 0
how can you solve your problem?
can you explain it in details to me?
i can give you 100 points.
And Ofcourse Classpath is also Important.
All the Best
Rajiv