简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM