Skip to main content

developerWorks >  Information Management  >  Forums  >  IBM Cloudscape and Apache Derby  >  developerWorks

Problem with Derby Embedded Server    Point your RSS reader here for a feed of the latest messages in this thread


     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
This question is answered.

Permlink Replies: 3 - Pages: 1 - Last Post: Oct 29, 2009 12:01 PM Last Post By: Stan Threads: [ Previous | Next ]
balcerman

Posts: 3
Registered: Oct 29, 2009 06:08:55 AM
Problem with Derby Embedded Server
Posted: Oct 29, 2009 06:10:08 AM
 
Click to report abuse...   Click to reply to this thread Reply
Hello,

I'm trying to launch Derby Embedded Server - Dervy version which you can use as both Embedded and Network Server.

The description is here:
http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#Embedded+Server

The problem is that I apparently can't launch it properly, since still I am able to connect with it in one way at one time - with Apache Derby Embedded driver or with Apache Derby Client driver, but not with both of them at once.

I get the stack trace ('derbyEmbeddedServer' is my database name, 'C:\Program Files\Sun\JavaDB\bin\derbyEmbeddedServer' is where my database is created):

java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ040, SQLERRMC: Failed to start database 'derbyEmbeddedServer', see the next exception for details.::SQLSTATE: XSDB6Another instance of Derby may have already booted the database C:\Program Files\Sun\JavaDB\bin\derbyEmbeddedServer.
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:133)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.execute(OpenConnectionCommand.java:97)
at net.sourceforge.squirrel_sql.client.mainframe.action.ConnectToAliasCommand$SheetHandler.run(ConnectToAliasCommand.java:280)
at net.sourceforge.squirrel_sql.fw.util.TaskExecuter.run(TaskExecuter.java:82)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.derby.client.am.SqlException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ040, SQLERRMC: Failed to start database 'derbyEmbeddedServer', see the next exception for details.::SQLSTATE: XSDB6Another instance of Derby may have already booted the database C:\Program Files\Sun\JavaDB\bin\derbyEmbeddedServer.
at org.apache.derby.client.am.Connection.completeSqlca(Unknown Source)
at org.apache.derby.client.net.NetConnectionReply.parseRdbAccessFailed(Unknown Source)
at org.apache.derby.client.net.NetConnectionReply.parseAccessRdbError(Unknown Source)
at org.apache.derby.client.net.NetConnectionReply.parseACCRDBreply(Unknown Source)
at org.apache.derby.client.net.NetConnectionReply.readAccessDatabase(Unknown Source)
at org.apache.derby.client.net.NetConnection.readSecurityCheckAndAccessRdb(Unknown Source)
at org.apache.derby.client.net.NetConnection.flowSecurityCheckAndAccessRdb(Unknown Source)
at org.apache.derby.client.net.NetConnection.flowUSRIDPWDconnect(Unknown Source)
at org.apache.derby.client.net.NetConnection.flowConnect(Unknown Source)
at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(Unknown Source)
... 6 more

Has anyone launched Derby Embedded Server successfully?
If so, may I ask for some steps on how to do that?

balcerman

Posts: 3
Registered: Oct 29, 2009 06:08:55 AM
Re: Problem with Derby Embedded Server
Posted: Oct 29, 2009 08:08:23 AM   in response to: balcerman in response to: balcerman's post
 
Click to report abuse...   Click to reply to this thread Reply
OK I did it :D

the problem is that setting the property
derby.drda.startNetworkServer=true

doesnt work to me, but when I added the following lines to my application:

import org.apache.derby.drda.NetworkServerControl;
import java.net.InetAddress;
NetworkServerControl server = new NetworkServerControl
(InetAddress.getByName("localhost"),1527);
server.start(null);

the Derby started to work as embedded server (which means that it is started by the application that contains these lines above and stopped while this application disconnects from Derby) but additionally you can connect to it via the port 1527, as in Network Server case :)

So the problem is solved to me.

balcerman

Posts: 3
Registered: Oct 29, 2009 06:08:55 AM
Re: Problem with Derby Embedded Server
Posted: Oct 29, 2009 08:08:37 AM   in response to: balcerman in response to: balcerman's post
 
Click to report abuse...   Click to reply to this thread Reply
OK I did it :D

the problem is that setting the property
derby.drda.startNetworkServer=true

doesnt work to me, but when I added the following lines to my application:

import org.apache.derby.drda.NetworkServerControl;
import java.net.InetAddress;
NetworkServerControl server = new NetworkServerControl
(InetAddress.getByName("localhost"),1527);
server.start(null);

the Derby started to work as embedded server (which means that it is started by the application that contains these lines above and stopped while this application disconnects from Derby) but additionally you can connect to it via the port 1527, as in Network Server case :)

So the problem is solved to me.

Stan

Posts: 429
Registered: Jan 25, 2005 06:45:18 PM
Re: Problem with Derby Embedded Server
Posted: Oct 29, 2009 12:01:29 PM   in response to: balcerman in response to: balcerman's post
 
Click to report abuse...   Click to reply to this thread Reply
Glad you got this working. Without the exact sequence that was executed I can only speculate as to what may have happened originally.

You wrote: the problem is that setting the property
derby.drda.startNetworkServer=true ... doesnt work to me

- This should start network server when the Derby driver is loaded (e.g. Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance()
EXAMPLE:
/*
If you are running on JDK 1.6 or higher, then you do not
need to invoke Class.forName(). In that environment, the
EmbeddedDriver loads automatically.
*/
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
Connection conn = DriverManager.getConnection(
"jdbc:derby:sample");

>> one thing that could have happened is that Network Server got started in a different JVM than you JDBC program (e.g. one of the IJ sessions loaded the driver first) or somehow was started in a different classLoader from the emedded driver (this can happen in App Server and IDE enivironments).

Hope this helps you determine what might have happened - if not and you would like to post the code used and sequence of events leading to the problem I will take a look at it to see if perhaps a bug has been introduced to Derby.
 Tags
Help

Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular type of content or application that you're viewing.

My tags shows your tags for this particular type of content or application that you're viewing.

 

MoreLess 


Point your RSS reader here for a feed of the latest messages in all forums