[netBeans] SQLException: No suitable driver

I try to establish a connection with my COFFEEBREAK database (jdbc:derby://localhost:1527/COFFEEBREAK) but the code

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

String url ="jdbc:derby://localhost:1527/COFFEEBREAK";

Connection conn = DriverManager.getConnection(url,"nbuser","nbuser");// exception

throws an exception

Exception in thread "main" java.sql.SQLException: No suitable driver

In Runtime->Databases->Drivers there are altogether 3 drivers:

- JDBC-ODBC Bridge

- Apache Derby (Net)

- Apache Derby (Embedded)

So what's the reason of that message?

Message was edited by:

bobens_83

[826 byte] By [bobens_83a] at [2007-11-26 17:56:24]
# 1
That message usually means that the class loader found your jdbc driver class, but the URL you gave to connect to the database has a syntax error.%
duffymoa at 2007-7-9 5:09:35 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

I have really no ideas how to modify my URL, could You give me a tip?

In the JDBC 'officicial' tutoral there's an example:

###########################################################

In place of " myLogin " you insert the name you use to log in to the DBMS; in place of " myPassword " you insert your password for the DBMS. So, if you log in to your DBMS with a login name of " Fernanda " and a password of " J8, " just these two lines of code will establish a connection: String url = "jdbc:derby:Fred";

Connection con = DriverManager.getConnection(url, "Fernanda", "J8");

###########################################################

I assume that 'Fred' is the name of database, so when I modify my url similarly

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

String url = "jdbc:derby:COFFEEBREAK";

Connection con = DriverManager.getConnection(url, "nbuser", "nbuser");

I receive an exception

Exception in thread "main" java.sql.SQLException: can'f find database 'COFFEEBREAK'.

Greetings

bobens_83a at 2007-7-9 5:09:35 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
did you create that database yet?%
duffymoa at 2007-7-9 5:09:35 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

DB is created, I can see it in Runtime->Databases->jdbc:derby://localhost:1527/COFFEEBREAK[nbuser on NBUSER]

When I right-clicked it and chose Connect - the connection would be properly established and I can create tables, procedures, etc.

So I'm giving my whole code, maby that's the reason package jdbc1;

import java.sql.*;

public class Main {

public static void main(String[] args) throws ClassNotFoundException, SQLException {

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

String url = "jdbc:derby://localhost:1527/COFFEEBREAK";

Connection con = DriverManager.getConnection(url, "nbuser", "nbuser");

}

}

bobens_83a at 2007-7-9 5:09:35 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
but 1 thing wonders me, when I enter database properties in the field Driver there is org.apache.derby.jdbc.ClientDriver, shouldn't be there sth different like Embedded Driver?
bobens_83a at 2007-7-9 5:09:35 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

Hello!!

I having some trouble whit and application that i made using the derby driver, and i want to know if any of you know what i can do.

I am using netbeans 5.5 and qhe a I run the project everything goes fine but when I build the project anf I try to execute I get the following error.

D:\sqlembebido\JavaDbAplication\dist>java -jar JavaDbAplication.jar

java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Unknown Source)

at database.DbConnector.<init>(DbConnector.java:25)

at javadbaplication.Main.main(Main.java:33)

java.sql.SQLException: No suitable driver found for jdbc:derby:clinica

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at database.DbConnector.<init>(DbConnector.java:41)

at javadbaplication.Main.main(Main.java:33)

Exception in thread "main" java.lang.NullPointerException

at objetos.Aseguradora.saveToDb(Aseguradora.java:48)

at javadbaplication.Main.main(Main.java:48)

Your help will be very useful.

Thank a lot.

simaxa at 2007-7-9 5:09:35 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...