I would like to use Derby in a Network Server Mode and followed the instructions on their website.
Starting derby:
/opt/glassfish/4.0/javadb/bin/NetworkServerControl start -noSecurityManager
Sun Apr 13 23:47:57 CEST 2014 : Apache Derby Network Server - 10.9.1.0 - (1344872) started and ready to accept connections on port 1527
Connecting with ij
:
$ /opt/glassfish/4.0/javadb/bin/ij
ij version 10.9
ij> connect 'jdbc:derby:testDB';
ij> create table testt ( x varchar(200), y varchar(200), z varchar(13));
0 rows inserted/updated/deleted
ij> select * from testt;
X
|Y
|Z
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0 rows selected
ij> commit;
ij>
Connecting to Derby in Java:
static{
try {
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
} catch (Throwable e) {
e.printStackTrace();
}
}
public void readData(){
final Connection connection = DriverManager.getConnection("jdbc:derby://localhost:1527/testDB");
....
}
The DriverManager.getConnection()
is failing with:
java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ040,
SQLERRMC: Failed to start database 'testDB' with class loader sun.misc.Launcher$AppClassLoader@23137792, see the next exception for details.::
SQLSTATE: XSDB6Another instance of Derby may have already booted the database
Haven't I just started derby in network server mode? Why am I getting this error?
DriverManager.getConnection("jdbc:derby:mydatabase;shutdown=true");
. This will throw informative exception which you can ignore. – Smilacaceous