• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

PROBLEMS IN CONNECTING TO ORACLE

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
}
}
}
}
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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");
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
instard of the native interface use the odbc bridge
 
reply
    Bookmark Topic Watch Topic
  • New Topic