aspose file tools*
The moose likes Other Open Source Projects and the fly likes Derby Embedded vs. Derby Network Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Derby Embedded vs. Derby Network Server" Watch "Derby Embedded vs. Derby Network Server" New topic
Author

Derby Embedded vs. Derby Network Server

Ismael Upright
Ranch Hand

Joined: Feb 15, 2007
Posts: 166
Hello,


Probably I will use Derby Embedded DB in my java project.

The problem is that Derby Embedded can handle only one connection at once. You can't connect to it with more than one application.

It's not a problem in production environment since the application will be standalone.

But it will be a problem in development environment, since I will probably need to debug the application. So I will be connected to Derby Embedded with my application I will debug, and at the same time I will need to see what's going on in the Derby Embedded - which means the connection to it from the application like SquirrelSQL.

Two connections needed while only one is allowed....




The solution I was thinking of is to use Derby Network Server instead of Derby Embedded, for the time of development. It allows multiple connections so the problem would be solved.

In the production environment I would still use Derby Embedded.

And here comes another problem and my question.....




Is it safe to use Derby Network Server in development environment, and then just switch to Derby Embedded in production environment?

In other words: does Derby Network Server and Derby Embedded differ much besides the number of connections allowed at the same time?
Ismael Upright
Ranch Hand

Joined: Feb 15, 2007
Posts: 166
Nobody knows?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Sorry it doesn't look like it, have you tried the derby support forums/mailing list?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

Ismael Upright wrote:Is it safe to use Derby Network Server in development environment, and then just switch to Derby Embedded in production environment?

In other words: does Derby Network Server and Derby Embedded differ much besides the number of connections allowed at the same time?


Drivers are completely different from one another. So i wouldn't say it's safe.

So I will be connected to Derby Embedded with my application I will debug, and at the same time I will need to see what's going on in the Derby Embedded - which means the connection to it from the application like SquirrelSQL.


Incidentally, i have been trying Derby (Embedded) in one of my application this week and that's exactly the kind of situation i am running into. As a workaround (although it doesn't work out very well, but is OK at the moment), i let my application run and create the DB and later on i start SquirrelSQL client to look into the created DB contents. Not very useful in debug situations. I was hoping there was some sort of multiple "read" clients and a single "read/write" client for Embedded server. That would have allowed the SquirrelSQL client to use the database in "read" mode simultaneously when my application would be using the same DB in read/write mode. Haven't found anything along those lines yet.

[My Blog] [JavaRanch Journal]
Ismael Upright
Ranch Hand

Joined: Feb 15, 2007
Posts: 166
Hey there

In the meanwhile I was reading Derby docs and I have found a third Derby DB kind - the Embedded Server.


Derby Embedded Server seems like some kind of merge of Derby Embedded and Derby Network Server - you can use both drivers to connect to it. It means that you can have your application connected to it with Embedded driver, and Squirrel connected to it with Network Server driver.


I haven't managed how to run it yet but this may be a good way.
Ismael Upright
Ranch Hand

Joined: Feb 15, 2007
Posts: 166
I tried to launch Derby Embedded Server - Derby version which you can use as both Embedded and Network Server.

The description (unfortunately not very long) 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 following 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?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I never have, but one thing you might want to try to to have derby installed in a path with no spaces in it (it might not like Program Files).
Ismael Upright
Ranch Hand

Joined: Feb 15, 2007
Posts: 166
OK I did it


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

It weren't spaces in the path but thanks tho
So the problem is solved to me.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Derby Embedded vs. Derby Network Server