Reputation: 2419
I'm trying to run the Apache Derby db from a flash drive. I copied the relevant .jar files and managed to start up the network server. But how to I specify the connection URL in connecting to the server? the database is in the flash drive labeled as G.
Used the following code, but came across an exception:
DriverManager.getConnection("jdbc:derby://localhost:1527");
java.sql.SQLException: The URL 'jdbc:derby://localhost:1527' is not properly formed.
How can I connect and use it as a normal database?
Thank You!
Upvotes: 1
Views: 1215
Reputation: 76709
The presence of the flash drive is immaterial to this question. The most pertinent point is whether the Derby server is running in the embedded mode or in the network server mode.
From the URL used, it appears that you intend to connect to Derby running as a network server. This would be the case if you've started Derby using the startNetworkServer
shell scripts, available in the Derby installation. If so, the connection URL format, as defined in the Derby documentation is as shown below. Note the presence of the databaseName
parameter, which is missing in the URL posted in the question.
jdbc:derby://server[:port]/databaseName[;attributeKey=value]..
If you didn't want to start Derby in the network server mode, but instead as an embedded database, then the connection URL format is different. Note the absence of the port number, and the reliance on a subprotocol whose value are one of directory
, classpath
or jar
. Examples of this format can also be found in the documentation.
jdbc:derby:[subsubprotocol:][databaseName][;attribute=value]*
Upvotes: 3