Hi,
My code is as follows, which is from http://www.kitebird.com/articles/jdbc.html but slightly modified. (My database is called "mrknowitall"):
__________________________________________________________________________________
import java.sql.*;
public class Connect
{
public static void main (String[] args)
{
Connection conn = null;
try
{
String userName = "root";
String password = "mypassword";
String url = "jdbc:mysql://localhost/mrknowitall";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Error message: " + e.getMessage ());
}
finally
{
if (conn != null)
{
try
{
conn.close ();
System.out.println ("Database connection terminated");
}
catch (Exception e) { /* ignore close errors */ }
}
}
}
}
__________________________________________________________________________________
I am able to compile and run it like so:
__________________________________________________________________________________
CLASSPATH=mysql-connector-java-5.1.14-bin.jar
javac Connect.java
java Connect
__________________________________________________________________________________
Problem is that I get this error:
__________________________________________________________________________________
Error message: com.mysql.jdbc.Driver
__________________________________________________________________________________
Any help much appreciated.
My code is as follows, which is from http://www.kitebird.com/articles/jdbc.html but slightly modified. (My database is called "mrknowitall"):
__________________________________________________________________________________
import java.sql.*;
public class Connect
{
public static void main (String[] args)
{
Connection conn = null;
try
{
String userName = "root";
String password = "mypassword";
String url = "jdbc:mysql://localhost/mrknowitall";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Error message: " + e.getMessage ());
}
finally
{
if (conn != null)
{
try
{
conn.close ();
System.out.println ("Database connection terminated");
}
catch (Exception e) { /* ignore close errors */ }
}
}
}
}
__________________________________________________________________________________
I am able to compile and run it like so:
__________________________________________________________________________________
CLASSPATH=mysql-connector-java-5.1.14-bin.jar
javac Connect.java
java Connect
__________________________________________________________________________________
Problem is that I get this error:
__________________________________________________________________________________
Error message: com.mysql.jdbc.Driver
__________________________________________________________________________________
Any help much appreciated.