Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
882 views
in Technique[技术] by (71.8m points)

database - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...