Sunday, December 2, 2007

Derby

I had a project work in which I needed to port an existing web-application running on MySQL toDerby. The SQL and datatypes of both are fairly same with minor variations (like syntax for triggers), though Derby does NOT support a few features like 'limit'.

TIPS:

If you are using embedded derby, remember, only ONE connection can be made to the database at a time. If applications running on different JVM's try to access the same database resource at the same time, then except the first one, none will be able to get access. So, go for Network server, if you have any such requirements.

----------------------------------------------

Username & Password

While creating the derby database, if username and password were not specified, and the application you are using requires one, then use the following if it doesn't accept blank/null fields

username: app
password: app

----------------------------------------------

Derby Network Server (for Windows)

Goto
%DERBY_INSTALL%\frameworks\NetworkServer\bin
and type "startNetworkServer.bat"

This will start the server and by default it will listen on port 1527

example:

In my machine Derby is installed in
C:\Program Files\Apache Software Foundation

So, value of the DERBY_INSTALL variable is "C:\Program Files\Apache Software Foundation\db-derby-10.2.1.6-bin"

So, the command "cd %DERBY_INSTALL%\frameworks\NetworkServer\bin"
opens up the following:
C:\Program Files\Apache Software Foundation\db-derby-10.2.1.6-bin\frameworks\Net
workServer\bin>

Now entering "startNetworkServer.bat" starts the server on port 1527

Remember, your derby database files must be located in the
"C:\> cd %DERBY_INSTALL%\frameworks\NetworkServer\bin" directory,
if you are run the server following the aforesaid.

From the program through which you wish access the database, give the following path of the database as:

"jdbc:derby://localhost:1527/dbname"

where 'dbname' is the name of the database.

If the database is located in some other folder, say D:/dbfolder, then modify the above as follows:

"jdbc:derby://localhost:1527/D:/dbfolder/dbname"

----------------------------------------------

Resources:

No comments: