exception com.sql.jdbc ?
here is my code, can anyone help me wats wrong with it?
is it the driver ?
plzzz....
tnx in advance...
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class second {
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "");
if(!con.isClosed())
System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}
[831 byte] By [
viciousa] at [2007-11-26 19:38:00]

# 5
I was able to connect it, just now, the problem is, wherever the com folder is ( in com.sql.jdbc.driver) it is where my java program works and able to connect to the database.....
if not, the program wont work.......
is it possible to have it work outside the "shadow" of the com folder?
here is the driver name: com.sql.jdbc.Driver
the classpath i think didnt work....?
my classpath is like this: . . . . . . c:\<the dir>\<the name of the driver.jar>
is that correct?
thanks for the help......
Message was edited by:
vicious
# 6
How are you setting the classpath? If you use an IDE, set the jar as one of the project libraries. If not, set it using -cp on the command line. In either case do not depend on the system environment variable.
P.S. And I hope you meant "com.mysql.jdbc.Driver" and not "com.sql.jdbc.driver" as you typed.
# 8
> ah its com.mysql.jdbc.driver....
> not .........sql........
>
>
> i use the environment variable, so its not reliable?
> thats why i said its useless.
>
> i will try the -cp on the command line...
>
> i just use notepad..........
>
> tnx.....
Also note that driver should be Driver.