4
I have developed an employee registration system. In this system the data persistence is done in a mysql database. When running the program by the package the system works normally, but when generating an executable jar it does not find the mysql driver.
mysql Driver is in the path below:
c:\jars\jdbc_mysql.jar
The main application class is in the package below:
br\com\vl1\principal\SistemaCadastro.java
Running the way below the system works:
c:\raiz\java -cp c:\jars\jdbc_mysql.jar;. br.com.vl1.principal.SistemaCadastro
But when I run as below it does not find the Mysql Driver
c:\raiz\java -cp c:\jars\jdbc_mysql.jar;. -jar SistemaCadastro.jar
The jar was generated with the following command:
jar -cvfm SistemaCadastro.jar META-INF\MANIFEST.MF br
Below follows the generated Exception when I try to save a record in the database:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/sistema_cadastro
The entire process was executed by the command prompt. I am not using IDE and would like a per-command-line solution.
If anyone can help me, I’d appreciate it.
Have you compiled the mysql driver jar together? If not, this is probably the cause.
– user28595