Reputation: 163
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