- Timestamp:
- 02/25/10 20:57:40 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.bridgedb.rdb/src/org/bridgedb/rdb/IDMapperRdb.java
r308 r317 17 17 package org.bridgedb.rdb; 18 18 19 import java.io.File; 20 import java.io.IOException; 19 21 import java.sql.Connection; 20 22 import java.sql.DriverManager; … … 22 24 import java.util.Collection; 23 25 import java.util.Map; 26 import java.util.Properties; 24 27 import java.util.Set; 25 28 … … 53 56 public IDMapper connect(String location) throws IDMapperException 54 57 { 55 return SimpleGdbFactory.createInstance(location, new DataDerby(), 0); 58 try 59 { 60 String url = "jdbc:derby:jar:(" + location + ")database"; 61 Connection con = DriverManager.getConnection(url); 62 return SimpleGdbFactory.createInstance(location, con); 63 } 64 catch (SQLException ex) 65 { 66 throw new IDMapperException(ex); 67 } 56 68 } 57 69 } … … 67 79 try 68 80 { 69 Connection con = DriverManager.getConnection("jdbc:" + location);70 71 return SimpleGdbFactory.createInstance(location, con , 0);81 String url = "jdbc:" + location; 82 Connection con = DriverManager.getConnection(url); 83 return SimpleGdbFactory.createInstance(location, con); 72 84 } 73 85 catch (SQLException ex) … … 86 98 public IDMapper connect(String location) throws IDMapperException 87 99 { 88 //TODO: make port and host configurable 89 DBConnectorDerbyServer.init ("wikipathways.org", 1527); 90 return SimpleGdbFactory.createInstance(location, new DBConnectorDerbyServer(), 0); 100 try 101 { 102 Map<String, String> args = 103 InternalUtils.parseLocation(location, "host", "port"); 104 105 if (!args.containsKey("BASE")) 106 throw new IllegalArgumentException("Expected species name in connection string: " + location); 107 108 String host = args.containsKey("host") ? args.get("host") : "wikipathways.org"; 109 String port = args.containsKey("port") ? args.get("port") : "1527"; 110 111 Class.forName("org.apache.derby.jdbc.ClientDriver"); 112 Properties sysprop = System.getProperties(); 113 sysprop.setProperty("derby.storage.tempDirectory", System.getProperty("java.io.tmpdir")); 114 sysprop.setProperty("derby.stream.error.file", File.createTempFile("derby",".log").toString()); 115 116 String url = "jdbc:derby://" + host + ":" + port + "/" + args.get("BASE"); 117 Connection con = DriverManager.getConnection(url); 118 return SimpleGdbFactory.createInstance(location, con); 119 } 120 catch (SQLException f) 121 { 122 throw new IDMapperException (f); 123 } 124 catch (IOException e) 125 { 126 throw new IDMapperException (e); 127 } 128 catch (ClassNotFoundException e) 129 { 130 throw new IDMapperException (e); 131 } 91 132 } 92 133 }
