Re: JDBC load problem -thanks Sanjay

From: Kevin McMurtrie <mcmurtri_at_sonic.net>
Date: 2000/05/07
Message-ID: <mcmurtri-63DDE7.19471006052000_at_news.sonic.net>#1/1


In article <8f282m$n34$1_at_nnrp1.deja.com>, el_squid_2000_at_my-deja.com wrote:

>Now I'm getting the following:SQLException from the following connect
>statement.
>
> Connection conn = DriverManager.getConnection(
>"jdbc:oracle:thin:demo/demo_at_tcp-example:1521:orcl")

That doesn't look like a valid URL.

Maybe "jdbc:oracle:thin:_at_tcp-example:1521:orcl" will work.

BTW, DriverManager.getConnection () is not efficient to use. It's syncrhonized so network problems will momentarily stop all attempts to open more connections. Here's a faster way:

//Need to hold onto something to keep GC away. //Yes, it happens.
final Class driverHolder=

   Class.forName("oracle.jdbc.driver.OracleDriver");

final String oracleURL= "jdbc:oracle:thin:_at_tcp-example:1521:orcl";

//Get the Oracle driver.
final Driver oracleDriver= getDriver(oracleDriver);

//Set user and password into a properties table. //Can set Oracle specific properties too, if needed. final Properties connectionProps= new Properties (); connectionProps.put ("user", "demo");
connectionProps.put ("password", "demo");

//Now get connections directly from the Oracle driver. Connection con= oracleDriver.connect (oracleURL, connectionProps);

>Below is the stack trace. I'm just using the SID, port number and
>service name from Net 8 Assistant. Any help appreciated.
>
>
>
>
>java.sql.SQLException: Io exception: The Network Adapter could not
>establish the connection at
>oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114) at
>oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156) at
>oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269) at
>oracle.jdbc.driver.OracleConnection.(OracleConnection.java:210) at
>oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:
>251) at
>oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:224) at
>java.sql.DriverManager.getConnection(Compiled Code) at
>java.sql.DriverManager.getConnection(DriverManager.java:159) at
>DBServlet.doPost(DBServlet.java:45) at
>javax.servlet.http.HttpServlet.service(HttpServlet.java:521) at
>javax.servlet.http.HttpServlet.service(HttpServlet.java:588) at
>org.apache.jserv.JServConnection.processRequest(JServConnection.java) at
>org.apache.jserv.JServConnection.run(JServConnection.java) at
>java.lang.Thread.run(Thread.java:479) A problem occured in Oracle.
>Please try again.
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy
Received on Sun May 07 2000 - 00:00:00 CEST

Original text of this message