db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Embretsen <John.Embret...@Sun.COM>
Subject Re: How to start Derby service with db in different locatoin
Date Tue, 22 Jan 2008 07:29:02 GMT
Raghunath wrote:
> Hi,
> I created my database from netbeans,by spcifying db location(All data 
> will go to that directory). 

The "Database Location" setting available from the "Tools -> Java DB Database -> 
Settings" menu in Netbeans only has effect on the Network Server when started 
from the NetBeans utilities/menus. It does not affect embedded connections, nor 
Network Server instances started by other means (e.g. command line, 
derbyrun.jar, Derby's Java API...).

> Then I ran my application with 4 
> connection/80 connection. 

Not sure what this means.. Do you mean 4 threads, 80 connections?

> After some time it's going outof memory.
> I analyzed that I can specify the -Xms jvm option in 
> startNetworkServer.bat (Not sure wil it solve the problem)

This will only have an effect if you are starting the Network Server using that 
script. If you start the server from NetBeans, it won't have any effect (I don't 
think you change the server's heap settings from NetBeans - yet).

If you need to use custom heap settings for the Network Server JVM, I recommend 
you start it from the command line, e.g. by using derbyrun.jar,

'java -Xmx512m -Dderby.system.home=YourDatabaseLocation -jar 
%DERBY_HOME%\lib\derbyrun.jar server start'

This gives you full control over which settings your server VM is actually 
running with. But there are several ways to do this, as you have discovered.

> And I want to rise my db (different directory location). 

Do you mean that you want to boot another database, at a different location?
Or that you want to access your database even if your working directory is 
different from the "Database location" setting in NetBeans?
Or something else?

> thru ij im able 
> to connect , but it's embeded connection manager i think
> ij>  connect 'jdbc:derby:H:\My 
> Dream\bb-jd-db\bb-jd-real-hyd;user=app;password=app;'
> but this time my application in failing to connect to the server.

Yes, this is a URL for the embedded driver. This will not even attempt to access 
the server. If the path to the database is correct, you will be able to connect 
to the database only if the database exists and the same database is not booted 
by another JVM (e.g. the Network Server, or NetBeans).

If the Network Server is running, you can access the database from IJ (and 
NetBeans) by using the client driver and a matching URL, for example

ij>  connect 'jdbc:derby://localhost:1527/H:/My 
Dream/bb-jd-db/bb-jd-real-hyd;user=app;password=app;'

Note that you should use forward slashes as path separator in the connection 
URL, even on Windows.

You can read more about URLs, embedded vs. client/server, database paths etc. in 
the manuals and in various other documents and tutorials. A good starting page 
is this:

http://db.apache.org/derby/quick_start.html

> But If i do the same from netbeans , the service is up and im able to 
> connect to db..but it's withou jvm -xms option

Then you are probably using the client driver from NetBeans.

If you are running out of memory, make sure you release (close and set to null) 
all resources to the JVM when you are done using them, such as ResultSets, 
Statements, PreparedStatements, Connections.

If you post details about what kind of database operations lead to the 
OutOfMemoryError, someone on this list may be able to assist as well.

I hope this helps somewhat...

-- 
John


Mime
View raw message