Reputation: 799
I have a programm uses JDBC. In intellij Idea programm run correctly, but in cmd after i compile class and run it i have Exception:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/blabla
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
Run from cmd with this command:
java -cp .;"D:\libs\poi-3.14-20160307.jar" Main
What's the problem?
I'm add source code by requestion.
Upvotes: 0
Views: 153
Reputation: 10560
poi-3.14-20160307.jar
doesn't look like the jdbc driver jar. Use this.
After you download the jar, unzip, place it where you want and then include it in your classpath like:
java -cp .;"D:\libs\poi-3.14-20160307.jar;D:\libs\mysql-connector-java-5.1.38-bin.jar" Main
Upvotes: 2
Reputation: 136122
You need to add MySQL driver for Java on the classpath. Try this one https://dev.mysql.com/downloads/connector/j/
Upvotes: 1
Reputation: 1541
You need to check your classpath to make sure you have the mysql driver in place.
Things like Maven are very good at controlling the classpath, and making sure you build with the correct libraries.
What does the build script look like in IntelliJ? How is the jar packaged?
Does your code contain Class.forName
?
Upvotes: 1