Java SQL error, no suitable driver found


I'm trying to compile this small piece of code, to help me connect to my db and retrieve some information to test it. I am using Netbeans on a Windows 7 x64 machine. This is the code:

package passwordprotector; import java.sql.*; public class PasswordProtector { /** * @param args the command line arguments */ public static void main(String[] args) { String host = "jdbc:derby://localhost:1527/PasswordProtector DB"; String dbUsername = "john"; String dbPassword = "arsenal"; /*try{ Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); }catch(ClassNotFoundException e){ System.out.println(e); }*/ try{ Connection con = DriverManager.getConnection(host, dbUsername, dbPassword); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM APP.PERSON"); while (rs.next()) { String uName = rs.getString("uname"); String uPass = rs.getString("upass"); System.out.println("Username: " + uName + "/n" + "Password: " + uPass); } }catch(SQLException e){ System.err.println(e); } } }

When I compile and run I receive this error:

java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/PasswordProtector DB BUILD SUCCESSFUL (total time: 0 seconds)

When I right click on my db and select properties I can see it's location, like so:

Database URL: jdbc:derby://localhost:1527/PasswordProtector

I've checked with others who have posted about this and it seems they had an incorrect URL as the issue, but I can't see any other URL which I can use apart from the one posted.

I've tried with and without the ending ' DB' for the String host, neither works.

I've also already read from <a href="http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html" rel="nofollow">here</a> and still couldn't figure out why the URl is incorrect:


Not sure the problem with the database URL connection, but in the usage of the correct driver. If the database is embedded you should use the driver commented in your post and example from my <a href="https://stackoverflow.com/questions/11864443/packing-embedded-database-in-jar-file/11867360#11867360" rel="nofollow">answer</a>, there's also <a href="http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html" rel="nofollow">tutorial embedded derby</a>.

if not then use


It's a different driver to connect to the database running standalone. In this case see <a href="http://db.apache.org/derby/papers/DerbyClientSpec.html" rel="nofollow">derby network client</a> documentation how to configure and run derby network client.


Make sure derbyrun.jar is in your classpath. It resides in the db/lib directory of your JDK.


Doing a quick search on Maven and Derby, included the following in my pom:

<dependency> <groupId>org.apache.derby</groupId> <artifactId>derbyclient</artifactId> <version></version> </dependency>

and everything worked afterwards, so it may be a library reference issue if the previous solution did not work.


  • PHP MySQL Connection error - Implementing Retry logic
  • How do I achieve queryaccelearation=all and packageset using Java JDBC?
  • Image.MemoryStream : Parameter not valid
  • Assign value to HTML textbox from JSP
  • delete sql not deleting
  • My sql: PacketTooBigException: Packet for query is too large (4,739,923 > 65,535)
  • Servlet error HTTP Status 405 - HTTP method GET is not supported by this URL
  • Java regex to remove SQL comments from a string
  • Hive2 & JDBC - Required field 'serverProtocolVersion' is unset
  • Clear the in memory database after every testcase
  • JDBC Transaction control in Sybase
  • Java regex to remove SQL comments from a string
  • com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to
  • Fail to convert to internal representation JDBC
  • How to return value from this function? [duplicate]
  • SQLException: the result set is closed
  • java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. [duplicate]
  • Error connecting to oracle. Getting an UnsatisfiedLinkError for the method t2cGetCharSet
  • TSQL: Prevent trigger suppressing error but rolling back transaction
  • Sqlite: Execute Spatialite Functions in Intellij
  • Why we should close the connection in JDBC? If we don't do it, what will happen
  • Beginner in SQLite
  • Smack 4.1.0 android Roster not displaying
  • If statement skipping right to else after being called once?
  • How to copy styled text in JTextPane
  • Why does it draw lines in the wrong place?
  • Reading a file into a multidimensional array
  • App restarts from wrong activity
  • Converting a WriteableBitmap image ToArray in UWP
  • Jetty Server not starting: Unable to establish loopback connection
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Why value captured by reference in lambda is broken? [duplicate]
  • How to get a value (ex: baseURL) in every Karate feature?
  • javascript inside java/jsp code
  • Validaiting emails with Net.Mail MailAddress
  • sending/ receiving email in Java
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • How does Linux kernel interrupt the application?