1

I am aware that there are tons of questions around about this problem but I tried every ungodly way to fix it, still no result.

I have created a "test" Derby database within Netbeans. Everything works fine, I can execute SQL commands, alter tables and all within application. But i have to start the server everytime when I open netbeans. But I want my application's itself to start the server with codes. I guess i tried everything to do it.

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

server = new NetworkServerControl(InetAddress.getLocalHost(),1527);
server.start(null);

conn = DriverManager.getConnection("jdbc:derby://localhost:1527/test;create=true;");

This is what i get if i dont start the server manually.

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

I tried different drivers, i tried putting jar and sdk files to my app file. I added permission to socket 1527 to java.security file.

No matter what i do, i must start the server manually or i get this chunk of code.

jeb
  • 78,592
  • 17
  • 171
  • 225
Sönmez
  • 11
  • 3
  • 1
    Either you need to run the server as an external application (as you are doing) or you need to run [Derby as an embedded database](http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html). You should not mix the two approaches. – Boris the Spider Sep 14 '14 at 10:40
  • 1
    Everything you are doing seems fine, and seems to match the documentation in http://db.apache.org/derby/docs/10.10/adminguide/radminembeddedserverex.html Do you get a 'derby.log' file created? If you pause your application after calling NetworkServerControl.start, can you see your listen port using 'netstat'? – Bryan Pendleton Sep 14 '14 at 18:27
  • It doesnt create a log file if it doesnt connect. It is creating the derby.log only if i start the server manually and the text in the file is : Apache Derby Network Server - 10.10.1.3 - (1557168) started and ready to accept connections on port 1527 I could not see any (1527) related port with netstat. tons of others starting from 14xx to 3xxx. – Sönmez Sep 15 '14 at 06:35

0 Answers0