1

I've inherited a project (and I have absolutly no experience of Java) and I'm rather stuck.

We have a server running redhat, which I needed to update one of the jar files. So I simply copied up the updated file and restarted the service for that file. However this process has worked on our other server I did that too but on this one it comes up with the below in the log file.

Exception: com.mysql.jdbc.Driver
SQLException: No suitable driver found for jdbc:mysql://localhost:3306/dbanme

The jar files are uploaded to a folder in the root of the website and within that jar folder is a lib folder where mysql-connector-java-5.1.6-bin.jar is located.

Does anyone know what I could be missing as I'm a newbie to linux aswell.

Thanks in advance

webdev27
  • 43
  • 1
  • 7

2 Answers2

2

java.sql.SQLException: No suitable driver found

This exception can have 2 causes:

  1. The JDBC driver is not loaded at all.
  2. URL does not match any of the loaded JDBC drivers.

Since the driver seems to be loaded , it look like that the URL is not valid on that machine:

jdbc:mysql://localhost:3306/dbname

Do you have mysql running and listening on port 3306 on that machine. Also make sure you hte schema dbname there.

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
  • 2
    I think your assumption that the driver is loaded is incorrect. A driver is only allowed to reject a URL based on the prefix, not on the fact that a machine is not running or running on a different port – Mark Rotteveel May 15 '13 at 11:37
0

You need only set that:

[jdbc:mysql://localhost/dbanme] 

instead of

[jdbc:mysql://localhost:3306/dbanme]

Because java compiler default understand a port 3306, so no need to fill "3306" after "localhost:"

slavoo
  • 5,798
  • 64
  • 37
  • 39