• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Derby Embedded vs. Derby Network Server

 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nobody knows?
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry it doesn't look like it, have you tried the derby support forums/mailing list?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ismael Upright
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I am mighty! And this is a mighty small ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic