Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> JDBC
Hi,
I'm trying to get a Java servlet up and running (written by somebody else) using JDK 1.2 and Apache 1.3 with JServ. When I invoke it, I get the error:
java.sql.SQLException: Invalid Oracle URL specified: OracleDriver.connect
I'm passing "jdbc:oracle:myp.di" (without the quotes) as my URL and a username and password to the database myp (also the ORACLE_SID). I also tried "jdbc:oracle:myp". I have no idea whether this is the correct form of the URL--I am basing it on the code, which checks that the string starts with "jdbc" followed by a colon, followed by "oracle" or "odbc" followed by another colon, and, I assume, something to indicate which database to connect to.
The error is occurring in the call to DriverManager.getConnection in the code below.
Does anyone know the correct form of the DB URL?
-Sam Fredland
Code
private static HashMap driverNames;
static {
driverNames = new HashMap(); driverNames.put("odbc", "sun.jdbc.odbc.JdbcOdbcDriver"); driverNames.put("oracle", "oracle.jdbc.driver.OracleDriver");}
public static XConnection getConnection(String dbURL, String username, String passwd) {
if( !dbURL.startsWith("jdbc:") ) { throw new DataBaseException("Bad URL " + dbURL);
}
String code = dbURL.substring(5).substring(0, dbURL.substring(5).indexOf(":")); String className = (String)driverNames.get(code); try { Class.forName(className);
} catch (Exception e) {
e.printStackTrace(); throw new DataBaseException("Cannot load Driver " + className);
}
try { Connection conn = DriverManager.getConnection(dbURL, username, passwd); return new XConnection(conn);
} catch (SQLException e) {
e.printStackTrace(); throw new DataBaseException(e.getMessage());
}
![]() |
![]() |