Skip to content

Commit 684513f

Browse files
committed
A dual world: Derby 10.4 and 10.14+
1 parent f797159 commit 684513f

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

org.bridgedb.rdb.construct/src/org/bridgedb/rdb/construct/DBConnectorDerbyServer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ public Connection createConnection(String dbName) throws IDMapperException
6565
try
6666
{
6767
sysprop.setProperty("derby.stream.error.file", File.createTempFile("derby",".log").toString());
68-
Class.forName("org.apache.derby.jdbc.ClientDriver");
69-
}
70-
catch (ClassNotFoundException e)
71-
{
72-
throw new IDMapperException (e);
68+
try {
69+
Class.forName("org.apache.derby.jdbc.ClientDriver"); // Derby 10.4
70+
System.out.println("Derby ClientDriver loaded");
71+
} catch (ClassNotFoundException e) {
72+
// ignore, probably we're running this with Derby 10.14 or higher
73+
}
7374
}
7475
catch (IOException f)
7576
{

org.bridgedb.rdb.construct/src/org/bridgedb/rdb/construct/DataDerby.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@ public Connection createConnection(String dbName, int props) throws IDMapperExce
123123
{
124124
sysprop.setProperty("derby.storage.tempDirectory", System.getProperty("java.io.tmpdir"));
125125
sysprop.setProperty("derby.stream.error.file", File.createTempFile("derby",".log").toString());
126-
Class.forName("org.apache.derby.jdbc.ClientDriver");
127-
}
128-
catch (ClassNotFoundException e)
129-
{
130-
throw new IDMapperException (e);
126+
try {
127+
Class.forName("org.apache.derby.jdbc.ClientDriver"); // Derby 10.4
128+
System.out.println("Derby ClientDriver loaded");
129+
} catch (ClassNotFoundException e) {
130+
// ignore, probably we're running this with Derby 10.14 or higher
131+
}
131132
}
132133
catch (IOException f)
133134
{

org.bridgedb.rdb/src/org/bridgedb/rdb/IDMapperRdb.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ public IDMapper connect(String location) throws IDMapperException
8989

9090
String host = args.containsKey("host") ? args.get("host") : "wikipathways.org";
9191
String port = args.containsKey("port") ? args.get("port") : "1527";
92-
93-
Class.forName("org.apache.derby.jdbc.ClientDriver");
92+
93+
try {
94+
Class.forName("org.apache.derby.jdbc.ClientDriver"); // Derby 10.4
95+
System.out.println("Derby ClientDriver loaded");
96+
} catch (ClassNotFoundException e) {
97+
// ignore, probably we're running this with Derby 10.14 or higher
98+
}
9499
Properties sysprop = System.getProperties();
95100
sysprop.setProperty("derby.storage.tempDirectory", System.getProperty("java.io.tmpdir"));
96101
sysprop.setProperty("derby.stream.error.file", File.createTempFile("derby",".log").toString());
@@ -102,10 +107,6 @@ public IDMapper connect(String location) throws IDMapperException
102107
{
103108
throw new IDMapperException (e);
104109
}
105-
catch (ClassNotFoundException e)
106-
{
107-
throw new IDMapperException (e);
108-
}
109110
}
110111
}
111112

org.bridgedb.rdb/test/org/bridgedb/rdb/Test.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ public void testSimpleGdb() throws ClassNotFoundException, IDMapperException, IO
151151
Class.forName("org.bridgedb.file.IDMapperText");
152152
Class.forName("org.bridgedb.rdb.IDMapperRdb");
153153
Class.forName("com.mysql.jdbc.Driver");
154-
// no longer needed?? Class.forName("org.apache.derby.jdbc.ClientDriver");
155154

156155
String fileName = "yeast_id_mapping";
157156
String fullName = fileName + ".txt";
@@ -181,8 +180,13 @@ public void testDerbyClient() throws IDMapperException, ClassNotFoundException {
181180
long start, end, delta;
182181
start = System.currentTimeMillis();
183182
Class.forName ("org.bridgedb.rdb.IDMapperRdb");
184-
Class.forName ("org.apache.derby.jdbc.ClientDriver");
185-
183+
try {
184+
Class.forName("org.apache.derby.jdbc.ClientDriver"); // Derby 10.4
185+
System.out.println("Derby ClientDriver loaded");
186+
} catch (ClassNotFoundException e) {
187+
// ignore, probably we're running this with Derby 10.14 or higher
188+
}
189+
186190
IDMapper mapper = BridgeDb.connect ("idmapper-derbyclient:Homo sapiens?host=www.wikipathways.org");
187191
end = System.currentTimeMillis();
188192
delta = end - start;

0 commit comments

Comments
 (0)