Dalibor
Dalibor

Reputation: 163

netbeans apache derby connection not working

I am currently learning how to use the embedded Apache Derby database using Netbeans. I watched a tutorial on youtube to see how to connect to the database and I wrote the same code as the one in the tutorial did. My problem now is that i get an error message which says that it couldn't find the driver i think.

Here's the error:

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

And here's my code:

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
        Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/contact", "nbuser", "nbuser");

        Statement st = con.createStatement();
        ResultSet rs =  st.executeQuery("SELECT * FROM APP.FRIENDS");
        ResultSetMetaData meta = rs.getMetaData();

        for(int i = 1; i != meta.getColumnCount(); i++){

            System.out.println(meta.getColumnName(i));

            while(rs.next()){

                for(int x = 1; x != meta.getColumnCount(); x++){
                    System.out.println(rs.getObject(x));
                }
            }
        }

Upvotes: 1

Views: 879

Answers (1)

Deepak Bala
Deepak Bala

Reputation: 11185

Include the JDBC jar for Apache Derby into your classpath.

Upvotes: 2

Related Questions