0
    try { 
 Connection con;
 con = DriverManager.getConnection("jdbc:derby:C:/Users/family/.netbeans-derby/MyDatabase;create=true");
 System.out.println("Id");
 PreparedStatement stmt;
 stmt = con.prepareStatement("Select * from PERSON;");
 ResultSet rs=stmt.executeQuery();
 while(rs.next())
            {
              String id=rs.getString(String.valueOf("ID"));
              String name=rs.getString("NAME");
              System.out.println(id);
              System.out.println(name);
            }

        }catch (SQLException err) {
           System.out.println(err.getMessage()+ "No matching word in database");
        }

Hi, I'm a newbie to java derby. I have read forums regarding on connecting derby database(embedded) in netbeans but still i didn't find the solution. I have already add the derby.jar and derbyclient.jar in the library but still the error reads this way, can someone help me fix this error:

errorcode:

Failed to start database 'C:/Users/family/.netbeans-derby/fine' with class loader sun.misc.Launcher$AppClassLoader@1a7bf11, see the next exception for details.No matching word in database

Hope someone will respond to my question, Thanks..!!

  • 1
    Please post the entire exception, including the chained part. – Mad Physicist Dec 11 '13 at 23:59
  • i get the same error when my project is already running and i run it again, so when i close all processes and run the project the database works fine.. I'm still working on this problem too – siriuseteor77 Jun 27 '19 at 15:56

1 Answers1

0

First, I believe you mixed up usage of prepareStatement vs. Statment Take a look at this link, so you get some ideas how to learn more. Difference between Statement and PreparedStatement

Second, with your SQL query you cannot use prepareStatment. If I understood what you want to do, your SQL query should look like this.

String sql = "Select * from PERSON WHERE Id=?";

another issue about your SQL query is not to mentin what shcema you used. becasue PERSON does not make sense here, it should be something like APP.PERSON

Try to take a look at this tutorial about how to use perparStatment in JDBC http://www.mkyong.com/jdbc/jdbc-preparedstatement-example-batch-update/

Third, I had an issue about where I should I create my database, so I advice you to creat it in side of the project folder. hint, use relative path in your getConncetion

At the end, you need to have more research because you got it all wrong. good luck

Community
  • 1
  • 1
Kick Buttowski
  • 6,709
  • 13
  • 37
  • 58