This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes PROBLEMS IN CONNECTING TO ORACLE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "PROBLEMS IN CONNECTING TO ORACLE" Watch "PROBLEMS IN CONNECTING TO ORACLE" New topic
Author

PROBLEMS IN CONNECTING TO ORACLE

Chandar S Vellithirumutha
Greenhorn

Joined: May 29, 2000
Posts: 15
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
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
instard of the native interface use the odbc bridge
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PROBLEMS IN CONNECTING TO ORACLE
 
Similar Threads
servlet & type4 driver
rs.beforeFirst() exception
Scrollable Result Sets
storing /retrieving blob data from SQL2000
JDBC/Oracle access problem