0

I'm using the Netbeans IDE and the application works fine when running in Netbeans.

Basically, when I compile the program as a Jar the application starts up normally but when I attempt to get to the portion of the program which needs to connect to the database there is no output. In Netbeans however I'm able to get the output from the database.

When I run the application in Netbeans with the database turned off, I'm getting the error:

java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.

If the database is started the application works normal in Netbeans. Basically I'm asking how do I run this outside of Netbeans. Sorry for a newbie question :)

UPDATE:

I went to properties of the the project and the Java DB Driver is in the Compile Libraries still doesn't seem to be working outside of Netbeans.

Danie
  • 11
  • 2
  • 1
    What's the error you get when you run it outside netbeans? You might not be including the database driver in the classpath while connecting from outside, did you check that? – Sudhanshu Umalkar Mar 28 '13 at 07:18
  • make sure the database driver path is relative to its location in jar. – Ankit Mar 28 '13 at 07:21
  • Seems you are using invalid credentials or the db url / port is incorrect. The error clearly says that the connection is refused. Can you connect to the database using some db client? – Sudhanshu Umalkar Mar 28 '13 at 07:24
  • 1
    Are you sure the database is actually up and running when you start your application from outside Netbeans? You could check by issuing `netstat -an | grep 1527` to see if there's any process listening on that port. – mthmulders Mar 28 '13 at 07:26
  • @AndreL How might I do that outside of the IDE? – Danie Mar 28 '13 at 07:39
  • Netbeans helps you in which they get the database running for you, normally you should have a server on which your db is running or you use an embedded DB. I think since you are closing Netbeans you have no DB running when you let your program run outside of your IDE – Andres L Mar 28 '13 at 07:40
  • check also the answer to this question, i think this can give you more understanding of the "under the hood" stuff which your IDE does for you. http://stackoverflow.com/questions/10085778/how-to-run-database-program-outside-the-netbeans-ide – Andres L Mar 28 '13 at 07:45
  • So I should use an embedded database? I'm currently using this driver org.apache.derby.jdbc.ClientDriver Also: Thanks for the link! – Danie Mar 28 '13 at 07:46
  • If you dont want to run your own server then yes, try this link http://www.sqlite.org/ – Andres L Mar 28 '13 at 07:49

1 Answers1

0

Derby can run either as an embedded database or as a client-server database.

Here's a great set of material to learn more about the basics of configuring and running Derby: http://db.apache.org/derby/docs/10.9/getstart/cgstutorialintro.html

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56