I'm trying to connect to embedded database Java DB from NetBeans 7.1.
this is what I tried:
try{
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String url = "jdbc:derby:market; create=true";
String db = "/artikli";
String user = "wolf";
String pass = "wolf";
String query = "SELECT * FROM artikli";
Connection conn = null;
Class.forName(driver);
conn = DriverManager.getConnection(url + db, user, pass);
java.sql.Statement stmt = conn.createStatement();
ResultSet res = stmt.executeQuery(query);
System.out.println(res.getString("naziv")); // naziv = column name
res.close();
}catch(Exception e){
}
My question is how to get data and print, or populate JTable with it, and is this connection good, thanks? thank you in advance.
catchclause is swallowing it. As Oleg suggested, print the exception so you can see it...