0

Hello,
I'm using Netbeans with JDK 7. I'm developing a swing desktop application with embedded derby database.
I'm using the following code.

Statement stmt;
        try {
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
            Connection conn =
                    DriverManager.getConnection("jdbc:derby://localhost:1527/HelloWorld", "userid", "password");
            stmt = conn.createStatement();
            String sql = "INSERT INTO TABLEEMP " +
                    "VALUES (" + Integer.parseInt(jTextField1.getText()) + ", '" + jTextField2.getText() + "')";
            stmt.executeUpdate(sql);
            JOptionPane.showMessageDialog(null, "Success");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());

When i'm running this piece of code in Netbeans it's working fine. But when I close NetBeans and doubly click on the JAR file, it's throwing the following error:
java.net.ConnectException : Error connectiong to server localhost on port 1527 with message Connection refused : Connect

So, how to connect derby DB for distributed jar ?
How can i overcome this. Please help...

2
Contributors
1
Reply
6
Views
2 Years
Discussion Span
Last Post by ~s.o.s~
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.