0

I am using java and derby database. I built derby database in netbeans IDE. I have created a executable jar file using clean and build option.

While running the project in netbeans, it connect to database goodly. But if I run executable jar file, it doesn't connect to the database.

Help me to create a executable jar file with derby database, It should run on any other system.Part of coding to connect database is

String str = textarea.getText();
    Class.forName(driver).newInstance();
    conn = DriverManager.getConnection(url+dbName,userName,password);
    String stm="select url from pingatabl where functn=?";
    PreparedStatement st = conn.prepareStatement(stm);
    st.setString(1, str);
     //Excuting Query
    ResultSet rs = st.executeQuery();
    if (rs.next()) {
    String s = rs.getString(1);
    //Sets Records in frame
    JFrame fm = new JFrame();
    fm.setVisible(true);
    fm.setSize(500,750);
    JEditorPane jm = new JEditorPane();
    fm.add(jm);
    jm.setPage(ClassLoader.getSystemResource(s));
4
  • Where is code? Please read : How do I ask a good question? Commented Oct 8, 2015 at 6:59
  • 1
    What are your jdbc connection properties? Is the database running in embedded or server mode? Commented Oct 8, 2015 at 7:00
  • Where is the database? Inside of the Jar file? On the file system next to the database? Running in a separate process on the network? Commented Oct 8, 2015 at 7:00
  • My database running in server mode. How to change it to embedded mode? Commented Oct 8, 2015 at 7:18

1 Answer 1

1

You are as novice as I was 2 years ago. The thing is that you have not installed derby at all. See, Derby is a database server and netbeans has its own version of derby. So, it runs when made to run inside Netbeans but does not start when run from an executable file. So, first, install derby from https://db.apache.org/derby/ and then start the server and then you can access it from the executable file. Also, I would recommend you to use MySQL server instead of derby. But, you can always use derby.

Sign up to request clarification or add additional context in comments.

1 Comment

Derby is mostly an embedded database. It does have a server, but not many people use it as a server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.