Search code examples
netbeansderby

NetBeans Create Database connection refused


Thu Aug 16 15:55:47 CDT 2018 : Apache Derby Network Server - 10.11.1.2 - (1629631) started and ready to accept connections on port 1888

Good! That's where I want it. I have it on port 1888 because port 1527 is already in use.

The problem is that NetBeans IDE 8.2 doesn't make obvious how to select port when creating a database.

From the Services tab, expand the Databases node then right click Java DB. Select Create Database. In the Create Java DB Database dialog, set Database Name, User Name and Password. Click OK.

An error occurred while creating the database: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused: connect..

How do I tell the Create Database feature that the server expects connections on port 1888?


Solution

  • https://netbeans.org/bugzilla/show_bug.cgi?id=115186 http://db.apache.org/derby/docs/10.11/ref/rrefattrib26867.html

    As a workaround, go straight to the New Connection feature. For example:

    Services tab > Databases node > right click > New Connection

    New Connection Wizard

    Driver: Java DB (Network)

    Next >

    Customize Connection

    Host: localhost

    Port: 1888

    Database: books

    User Name: deitel

    Password: deitel

    JDBC URL: jdbc:derby://localhost:1888/books;create=true

    The important thing is the create=true attribute. Without it, you'll get:

    Cannot establish a connection to jdbc:derby://localhost:1888/books using org.apache.derby.jdbc.ClientDriver (The connection was refused because the database books was not found.)

    There you have it. You've just created a database and a connection to it at the same time from within the NetBeans IDE. Along the way, you have the ability to select the port on which the server is already expecting a connection.