I am new on working with java(Embedded) databases and derby. I am creating a java application in netbeans ide 8.0. I was able to set up the database and insert data on it. I tried to select rows on one of my db's tables and as expected I saw the rows i inserted. But when i try to select from my code/project, it returns no result. The connection is successfully established as per the logs and no errors encountered. I don't know what to do anymore. :(
Here's my code:
try {
Connection con = DriverManager.getConnection("jdbc:derby:AccountingDB"); /* Note use' / 'and not' \' The url above will be different in your system*/
PreparedStatement stmt = con.prepareStatement("SELECT * from app.companies");
ResultSet rs = stmt.executeQuery();
if(rs.next())
{
companySet.addItem(rs.getString("name"));
//System.out.println("Id : "+rs.getInt(1) +" "+" Fruitname :"+rs.getString(2));
}
else
{
System.out.println("No word matching in database");
}
} catch (SQLException err) {
System.out.println(err.getMessage()+ "No matching word in database");
}
i did this on the customize code of my jComboBox.
thanks. I hope I explained my problem well. :(