Hi
When I use the following code to connect with system account it works.
but when I used it to connect with another account that has dba privilge it
gives IO Exception!
Can someone help.
import java.sql.*;
public class OraThin
{
static String s;
public static void main(String[] args) throws ClassNotFoundException, SQLException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@pc_name:1521:orcl";
Connection conn =DriverManager.getConnection(url,"user", "password");
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
s= "SELECT * from table_name";
ResultSet rset = stmt.executeQuery(s);
while (rset.next()) {
// Get the data from the row using the column name
s = rset.getString("col_1");
}
stmt.close();
System.out.println (s);
}}
Exception in thread "main" java.sql.SQLException: Io exception: The Network Adap
ter could not establish the connection
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.ja
va:74)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:1
10)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:171)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:227)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:494)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
490)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:202)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio
n.java:33)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:465)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at OraThin.main(OraThin.java:10)