user2890017
user2890017

Reputation:

Error: in JAR with mysql-connector-java-5.0.7-bin

I have created Simple java application in netbeans IDE. i have used mysql-connector-java-5.0.7-bin to connect java with mysql.it works fine in IDE finally i have created executable jar.. when i run the jar file from cmd window i got the following error in cmd

db not connected -connectionjava.lang.ClassNotFoundException: com.mysql.jdbc.Dr
ver
db not connected -connectionjava.lang.ClassNotFoundException: com.mysql.jdbc.Dr
ver
connecting to the database
Invalid userjava.lang.NullPointerException
db not closedjava.lang.NullPointerException
its is from else

can any one help me to solve this one?

Upvotes: 0

Views: 551

Answers (2)

RINA
RINA

Reputation: 11

It was not possible to create a database connection with the given parameters. Please check the Exception below. There can be two reasons for this error: •Your database is down, or •Your database is not accessible with the given connection parameters. Be also aware that Alkacon recommends to use the following JDBC drivers for MySQL 4.1.x & 5.0.x: [mysql-connector-java-5.0.7-bin.jar] Check that the Jdbc drivers are included in your class path.

Error connecting to database using: "jdbc:mysql://localhost:3306/".


java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:885) at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3421) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1247) at com.mysql.jdbc.Connection.createNewIO(Connection.java:2748) at com.mysql.jdbc.Connection.(Connection.java:1553) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.opencms.setup.CmsSetupDb.setConnection(CmsSetupDb.java:480) at org.apache.jsp.setup.step_005f4a_005fdatabase_005fvalidation_jsp._jspService(step_005f4a_005fdatabase_005fvalidation_jsp.java:93) at

Upvotes: 1

Dror Bereznitsky
Dror Bereznitsky

Reputation: 20376

You will need to add the mysql-connector-java-5.0.7-bin.jar to your classpath when running your application.
The class path is the path that the Java runtime environment searches for classes and other resource files. The classpath can be set using either the -classpath option when calling a JDK tool (the preferred method) or by setting the CLASSPATH environment variable.
For example:

java -classpath mysql-connector-java-5.0.7-bin.jar;. com.foo.Main

Upvotes: 0

Related Questions