Wednesday, October 03, 2007

How to change the host and port for Java DB server in NetBeans

This issue has come up a number of times on the mailing list, so I thought I'd post it here for posterity.

The question is: how do you configure the Java DB Network Server, like set its host and port number, for the server that NetBeans starts and stops for you?

The sad answer is: you can't from the IDE. There is a bug logged for this.

However, you can do this by editing the derby.properties file.

First, find out where your database directory is. In NetBeans 6, go to Tools->Java DB Database->Settings and see the value for Database Location

For NetBeans 5.5, go to the Preferences/Options panel for NetBeans, choose Advanced Options, and then under IDE Configuration->Server and External Tools Settings->Java DB Database look at Database Location.

Under that directory, edit derby.properties. The file should be there; if it's not, create it.

Then add

# Change host setting so you will accept connections from any host
derby.drda.host=0.0.0.0

# Change port number if you don't want to use the default of 1527
derby.drda.portNumber=8080

Then for both NetBeans 5.5 and NetBeans 6, do Tools->Java DB Database->Stop Server and then Start Server.

The new properties should now be applied.

2 comments:

  1. Anonymous6:58 AM

    Hi David
    Thanks for the tip, I tried it and it works like magic.
    One problem I encountered though is when you try to create a data base using tools it tries to open the “old” port and not the new one, I set the port to 21527 but when creating the data base it tries to open 1527.
    Any thoughts?
    Thanks from Jack Solomon from Joburg in South Africa

    ReplyDelete
  2. Anonymous6:28 AM

    Hi,
    I created the database by making a connection like this:

    jdbc:derby://localhost:21527/mydb;create=true

    Hope this helps.
    Fred

    ReplyDelete