0

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. :(

rowrow
  • 93
  • 10
  • Try looking at these related questions: http://stackoverflow.com/questions/9494761/where-is-derby-database-stored-when-i-create-it-from-netbeans?rq=1 or http://stackoverflow.com/questions/17771832/where-does-netbeans-create-derby-embeded-db?rq=1 http://stackoverflow.com/questions/16759252/querying-embedded-database-in-netbeans-using-derby?rq=1 and see if that gives you some ideas about how to give us more information and ask a more precise question. – Bryan Pendleton Jul 27 '16 at 13:55
  • 1
    thanks Bryan! found some tips on your answer. it seems like I am pointing to another db location. thank you so much again! – rowrow Jul 28 '16 at 00:03

0 Answers0