This question already has an answer here:
- The infamous java.sql.SQLException: No suitable driver found 13 answers
Hi i have found a seemingly common problem, i cant interact with a mysql db. This no suitable driver found keeps happening. I have followed most threads on this same question, however i was not able to replicate their solution so am posting my own specific question.
(Mostly this thread: I can't load the JDBC driver for MySQL)
My code:
public DBManager(){
try {
//Class.forName("com.mysql.jdbc.Driver");
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
con=DriverManager.getConnection("jdbc:mysql:3306//localhost/test","root","root");
//con=DriverManager.getConnection(c);
if(!con.isClosed()) {
con.close();
}
}
catch (SQLException e) {
e.printStackTrace();
}
Now, i read that on newer drivers you dont need either Class.forName () or registerDriver(); i have tried both and i still cant get it to work.
The thing is am developing on a windows machine, with eclipse Indigo and Connector/J 5.1.17
and deploying (and debugging) on a remote linux with the same Connector.
Am launching my debug sessions with
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8998,server=y -classpath /home/dev/mysql-connector-java-5.1.17-bin.jar -jar devserver.jar
and i get that exception. Any help?
I come from a heavy c# development environment, so if i have to meddle with classpaths and such please try to step it by step as im not very familiar with that.