Problem while trying to connect to mySql server via JDBC...
Posted by: vroxopoios
Date: December 14, 2004 05:49PM

I am using a very simple Java program for connecting to an also simple mySql database. I am using J2SE v.1.4.1, mySql v. 4.1 and the 3.1.5-gamma version of the mysql connector/J. I have of course installed the connector as specified in the documentation, by copying the 'mysql-connector-java-3.1.5-gamma-bin.jar' file in the $JAVA_HOME/jre/lib/ext directory, which is also declared in the CLASSPATH environment variable.

The code is very simple, something like this:
public static void main(String[] args)
} catch (Exception e)
System.out.println("Problem Description: " + e.getMessage());

String username = "root";
String password = "root";
String url = "jdbc:mysql://localhost/test";

Connection con = DriverManager.getConnection(url,username,password);
//Connection con = DriverManager.getConnection("jdbc:mysql:///test?user=root&password=root");

Statement stmt = null;
ResultSet rs = null;

stmt = con.createStatement();
rs = stmt.executeQuery("SELECT ....");
} catch (SQLException se)

Although everything is kept as simple as possible, and should be working according to the documentation, the following errors occur when running the code:

Problem Description: com.mysql.jdbc.Driver
-----> from the 1st try-catch block

No suitable driver
-------> from the 2nd try-catch block

I have tried to create the Connection object using both ways as seen from the code fragment above, but with no luck eitherways...
Please note that I haven't written Java code for a long time, so there might be a chance that there is a coding error from my part, although I think that's not the case...
It is not my first time dealing with JDBC though; I have used Oracle DBMS and driver succesfully in the past. But is seems that we are not getting along well with mySql so far :(

Any ideas? Sorry for the long post.
Thank you in advance for your assistance.

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.