Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

data sources derby - connection refused

I am trying to connect a database with a java project. After reading some tutorials and the course support, I have understood that I need to make a new data source under the Admin Console.

So, I've logged in into the admin console, then navigated to Resources -> JDBC -> Data Sources -> New; filled in the fields and when I am testing the connection, the error I get is this one:

Messages The test connection operation failed for data source MyDB on server server1 at node RO2CVG6CNode01 with the following exception: java.sql.SQLNonTransientException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.DSRA0010E: SQL State = 08001, Error Code = 40,000. View JVM logs for further details.

I don't know where the problem is. Maybe with the Database name: jdbc:derby:D:\MyDB ? Can anyone help me please? I've also tried to use only MyDB, after this tutorial.
But still it doesn't work.

like image 647
Steffi Avatar asked May 02 '12 20:05

Steffi


2 Answers

Do you have the Derby Server running?

It's quite possible that you are trying to connect to a database without the actual server running on Port 1527.

You could try establishing a connection using the command line / linux shell - depending on what operating system you are using.

Try this if you like:

  1. Open a command prompt
  2. Navigate to your Derby installation directory
  3. Navigate to the "bin" directory(Note:Navigate Further to networkServer folder if it exists)
  4. Type "startNetworkServer" and press Enter

You should get a message that says something like this:

2012-08-29 10:57:16.559 GMT : Security manager installed using the Basic server security policy. 2012-08-29 10:57:16.809 GMT : Apache Derby Network Server - 10.6.2.1 - (999685) started and ready to accept connections on port 1527

If you don't, then maybe you could check your firewall (comments invited here :)

If you do, then you could test your connection using the following method:

  1. Open another command prompt
  2. Navigate to your Derby installation directory
  3. Navigate to the "bin" directory
  4. Type "ij" and press Enter
  5. Type the following:

     connect 'jdbc:derby://localhost:1527/MyDB';
    

    ...and press Enter

If all goes well, you will get the "ij>" prompt back.

From here you could enter some SQL queries to test the connection further.

If not, then there might be some other problems.

If you are creating the database for the first time in derby, then you would have to use this in place of Step 5 above:

     connect 'jdbc:derby://localhost:1527/MyDB;create=true';

...and press Enter

Hopefully after doing these things, you will get a connection. In the last instance, you will at least get a new database called MyDB that is active on the Derby Server. If your original database (MyDB) is relatively small, then it might be quicker just to reconstruct it again for whatever purpose you need it for.

Further to this, if you do establish a connection, then you could try other tools that you use for database development, since you have at least eliminated the possibility that the connection is the problem.

Just be sure to check the port number that is reported from Step 4. This is usually 1527. If not, then change the port number in Step 5 (or its replacement command for a new database) for whatever port is stated in the message from Derby.

Hope this helps and good luck :)

Wayne Riesterer

like image 121
Wayne Riesterer Avatar answered Oct 16 '22 07:10

Wayne Riesterer


Did you define an authentication alias? Seems to be the same problem as the one in link below;

http://www.webspheretools.com/sites/webspheretools.nsf/docs/Error%20when%20testing%20a%20JDBC%20connection%20to%20Derby

Also if you check SystemOut.log you may see an error message telling which property is not set;

{"08001","Required Derby DataSource property {0} not set.","40000"},

like image 27
Kurtcebe Eroglu Avatar answered Oct 16 '22 09:10

Kurtcebe Eroglu