db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: NPE when connecting to database with securityMechanism=8
Date Thu, 23 Aug 2007 10:15:44 GMT
Alan Burlison <Alan.Burlison@Sun.COM> writes:

> Knut Anders Hatlen wrote:
>
>> I don't think you can set derby.drda.securityMechanism for a single
>> database. You would have to set it for the entire server process, either
>> by starting the Java process with -Dderby.drda.securityMechanism=XXX, or
>> by putting derby.drda.securityMechanism=XXX into derby.properties.
>
> Ah right, that certainly would explain the problems I've been having.
> I assume I could also use System.setProperty() before using
> NetworkServerControl.start() the derby network server.

Yes, that should also do the trick.

> I'm using
> Derby inside a tomcat instance, but I want it to run in network server
> mode rather than embedded mode so I can use external scripts for doing
> things such as database backups, rather than having to do everything
> inside tomcat.
>
> The NPE still looks like a derby bug though, irrespective of my mistake ;-)

I agree, that shouldn't have happened. It would be great if you could
file a bug report at http://issues.apache.org/jira/browse/DERBY.

> I'm also a little confused on how to access a database once the
> network server is is running, from inside the same JVM that contains
> the network server.  By mistake I forgot to change the URL from the
> one used by the embedded driver:
>
> db = DriverManager.getConnection("jdbc:derby:mydb", props);
>
> to the one needed by the network driver
>
> db = DriverManager.getConnection("jdbc:derby://localhost/mydb", props);
>
> but the database still seemed to open OK, which is rather odd...

The network server actually uses the embedded driver to perform database
operations, so any application running in the same JVM as the server
could have access to the database directly through the embedded
driver. In your setup, I think it would make sense to use Derby this
way. The servlets could access the database without doing any network
I/O, and thereby improving the performance, whereas the external scripts
could use the network client driver and don't involve Tomcat. Derby's
manuals call this configuration an "Embedded Server" (see
http://db.apache.org/derby/docs/10.3/adminguide/cadminov17524.html).

-- 
Knut Anders

Mime
View raw message