Here is my code for connecting to Personal Oracle 8.0.3.0.0. The program compiles well and when i tried running this program i am getting the following exception. (I have downloaded the Oracle driver and set apppriate classpath.) java.sql.SQLException The network Adapter could not establish 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.OracleConnection.<init>(OracleConnection.java:210) at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver java:251) at oracle.jdbc.driver.OracleDriver.Connect(OracleDriver java:224) at oracle.jdbc.driver.OracleDriver.getConnection(DriverManager java:457) at oracle.jdbc.driver.OracleDriver.getConnection(DriverManager java:137) at DBConnection.main(DBConnection.java,Compiled Code)
Can any one help me. :confused Thanks a bunch Chandar import java.io.*; import java.sql.*; public class DBConnection { public static void main(String args[]) { Connection con = null; Statement stmt; try { Class.forName("oracle.jdbc.driver.OracleDriver"); DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); // DriverManager.registerDriver( // new oracle.jdbc.driver.OracleDriver()); con = DriverManager.getConnection("jdbc racle:thin:@:1521:","scott","tiger"); stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SElect username from registry"); while (rs.next()) { System.out.println("name - " + rs.getString("username")); } }catch(ClassNotFoundException e) {System.out.println("CLASSNOT FOUND"); e.printStackTrace(); } catch(SQLException e) {System.out.println("SQLException "); e.printStackTrace(); } catch(Exception e) {System.out.println("Exception "); e.printStackTrace(); } finally{ if (con!=null) try { con.close(); }catch(Exception e) { System.out.println("Exception @ close"); e.printStackTrace(); } } } }
Mejo Tom Vakanil
Greenhorn
Joined: Jun 06, 2000
Posts: 4
posted
0
For getting a connection object, you should mention the host on which the Oracle Server is running & the connect string So the statement should be :- con = DriverManager.getConnection("jdbc racle:thin:@:HOST_NAME:1521:CONNECT_STRING","scott","tiger");
Srinath R
Ranch Hand
Joined: Jun 28, 2000
Posts: 71
posted
0
instard of the native interface use the odbc bridge