2
I’ve been trying for a while to get my Mysql database connected by getConnection()
. I’ve tried several different ways, to put the name of the bank, I’ve seen several tutorials including tutorials that are from the Mysql site itself, videos, posts on the internet and none of the solutions there views solved my problem!
I am trying to use the format that does not use the driver manually since in the most current versions of java this is done automatically.
Follow a print of the code I ran next to the connected database.
The error is as follows:
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:mysql:@localhost:3306/Java
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at acessobanco.AcessoBanco.main(AcessoBanco.java:14)
/Users/Alecell/Library/Caches/NetBeans/8.1/executor-snippets/run.xml:53: Java returned: 1
FALHA NA CONSTRUÇÃO (tempo total: 0 segundos)
I use Netbeans on Mac with MAMP. Initially the port of Mysql was 8889, I came to think that would be the problem and modified to 3306 even so did not work. I did a check of whether the database is working on the new port (3306) with Mysqlworkbanch and is actually working, I just can’t make the connection via java code.
The JDBC was installed in several different ways and the mysql-Connector-java-5.0.8-bin. jar in fact it is in the library of the project.
Hi Alexandre, could you please post the code in text format instead of an image? Hugs.
– Anthony Accioly