Derby data sources - connection refused

I am trying to connect a database to a java project. After reading some tutorials and supporting the course, I realized that I needed to create a new data source in the admin console.

So, I went into the admin console, then went to Resources -> JDBC -> Data Sources -> New; filled with fields, and when I test the connection, the error I get is this:

Messages Failed to make a test connection for the MyDB data source on server1 in node RO2CVG6CNode01 with the following exception: java.sql.SQLNonTransientException: java.net.ConnectException: Error connecting to localhost server on port 1527 with the Connection message refused: connect.DSRA0010E: SQL State = 08001, error code = 40,000. Browse the JVM logs for more details.

I do not know where the problem is. Perhaps with the database name: jdbc: derby: D: \ MyDB? Can anybody help me? I also tried to use only MyDB, after this tutorial .
But still it doesn’t work.

+8
database derby websphere datasource
source share
4 answers

Does Derby Server work for you?

It is possible that you are trying to connect to a database without a real server running on port 1527.

You can try to establish a connection using the command line / Linux shell - depending on which operating system you are using.

Try it if you want:

  • Open command prompt
  • Go to the Derby installation directory
  • Go to the bin directory (Note: go to the networkServer folder, if one exists)
  • Type "startNetworkServer" and press Enter

You should receive a message that says:

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

If you do not, perhaps you can check your firewall (comments here :)

If you do this, you can test your connection using the following method:

  • Open another command line
  • Go to the Derby installation directory
  • Go to the bin directory
  • Type "ij" and press Enter
  • Enter the following:

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

    ... and press Enter

If all goes well, you will receive an "ij>" prompt.

Here you can enter some SQL queries to further test the connection.

If not, then there may be other problems.

If you are creating a database for the first time in a derby, you will have to use this instead of step 5 above:

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

... and press Enter

Hopefully after completing these steps you will get a connection. In the latter case, you will at least get a new MyDB database that is active on Derby Server. If your source database (MyDB) is relatively small, it might be faster to restore it again for whatever purpose you need.

In addition to this, if you have established a connection, you can try other tools that you use to develop the database, since you have at least eliminated the possibility that the connection is a problem.

Just make sure the port number is listed in step 4. Usually it is 1527. If not, change the port number in step 5 (or its replacement command for the new database) for any port specified in the message from Derby.

Hope this helps and good luck :)

Wayne Rister

+27
source share

Have you defined an authentication alias? The problem seems to be the same as in the 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 will see an error message indicating which property is not set;

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

+1
source share

Check out the apache derby documentation here .....

Configure the environment to use the JDBC driver for the Derby network client

To use the Derby Network Client JDBC driver, set CLASSPATH to include the jar files listed below:

  • derbyclient.jar: contains the JDBC driver
  • derbytools.jar: optional, provides the ij tool

You can explicitly specify your CLASSPATH using the command shown below: Windows:

 C:\> set CLASSPATH=%DERBY_INSTALL%\lib\derbyclient.jar;%DERBY_INSTALL%\lib\derbytools.jar;. 

UNIX:

 $ export CLASSPATH=$DERBY_INSTALL/lib/derbyclient.jar:$DERBY_INSTALL/lib/derbytools.jar:. 

Then try to create such a database after entering the ij command at the prompt ..... ij> connect

 jdbc:derby://localhost:1527/Chapter01DB;create=true; 
+1
source share
  • Download the derby to the following location:

     /home/ <user_directory> /apache-derby/ 
  • Setting the installation path / path as shown below:

     export DERBY_HOME=/home/<user_directory>/magister-database export DERBY_INSTALL=/home/<user_directory>/apache-derby/db-derby-10.11.1.1-bin export CLASSPATH=$DERBY_INSTALL/lib/derbyclient.jar:$DERBY_INSTALL/lib/derbytools.jar:$CLASSPATH 
  • Start the network server:

     /home/<user_directory>/apache-derby/db-derby-10.11.1.1-bin/bin/startNetworkServer 
  • Run the derby command line command as shown below:

     java org.apache.derby.tools.ij connect 'jdbc:derby://localhost:1527//home/<user_directory>/<database-directory>/<database-name>'; show tables; disconnect; exit; 
+1
source share

All Articles