No suitable error ?
Posted by: pompelmo
Date: October 18, 2004 01:55AM

Hello,
I am running mysql and Jconnector on a gentoo.
I have this code

import java.sql.*;

public class database {
private Connection connection;
private String driverName;
private String serverName;
private String mydatabase;
private String url;
private String username;
private String password;
private Statement stmt;
private ResultSet rs;

database() {
this.connection = null;
//try { this.connection.setReadOnly(true); } catch (SQLException e) { };
this.stmt = null;
this.rs = null;
this.driverName = "org.gjt.mm.mysql.Driver"; // MySQL MM JDBC driver
try { Class.forName(this.driverName); } catch (ClassNotFoundException e) { };
this.serverName="localhost";
this.mydatabase = "*****";
this.url= "jdbc:mysql://" + serverName + "/" + mydatabase;
this.username = "****";
this.password = "****";
this.connetti();
}

private void connetti() {

try {

this.connection = DriverManager.getConnection(this.url, this.username, this.password);

} catch (SQLException e) {
// Could not connect to the database
System.out.println("Can't connect to database.\nError: " +e);
}
}
.....



and this is the error:

Can't connect to the database.
Error: java.sql.SQLException: No suitable driver

Of course the database name, user and password are correct and i put my jconnector on:
/opt/sun-jdk-1.4.2.05/jre/lib/mysql-connector-java-3.0.15-ga-bin.jar
Near others jar classes....what is the problem?

Note: this code on win32 worked

Options: ReplyQuote


Subject
Written By
Posted
No suitable error ?
October 18, 2004 01:55AM
October 18, 2004 07:32AM
October 24, 2004 07:14PM


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.