From: "C. Ferguson" Subject: Re: JDBC Date: 2000/01/04 Message-ID: <38722576.65DF8451@rationalconcepts.com>#1/1 Content-Transfer-Encoding: 7bit References: X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@home.net X-Trace: news1.alsv1.occa.home.com 947004707 24.5.135.200 (Tue, 04 Jan 2000 08:51:47 PST) Organization: @Home Network MIME-Version: 1.0 NNTP-Posting-Date: Tue, 04 Jan 2000 08:51:47 PST Newsgroups: comp.database.oracle,comp.databases.oracle,comp.databases.oracle.misc,comp.databases.oracle.server Hi Sam, since you didn't specify what driver you are using, I'm going to refer you to a white paper on the oracle site. Please see http://www.oracle.com/java/jdbc/templates.html cheers. cindy Sam Fredland wrote: > 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()); > } > }