title: Java DB - Starting Server within application
body: <p>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.</p>
  
  <p>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.</p>
  
  <pre><code>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;");
  </code></pre>
  
  <p>This is what i get if i dont start the server manually.</p>
  
  <pre><code>java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.
  </code></pre>
  
  <p>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.</p>
  
  <p>No matter what i do, i must start the server manually or i get this chunk of code.</p>