class test
{
public static void main (String args [])
throws SQLException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
/* try{
Class.forName("oracle.jdbc.driver.OracleDriver"
}catch(Exception e){
System.out.println("No Driver!"
}
*/
// Connect to the database
// You must put a database name after the @ sign in the connection URL.
// You can use either the fully specified SQL*net syntax or a short cut
// syntax as ::. The example uses the short cut syntax.
String url = "jdbcracle:thin202.197.237.90:1521:mydomain";
String userName = "scott";
String password = "tiger";
// Create a Statement
Statement stmt = conn.createStatement ();
// Select the ENAME column from the EMP table
ResultSet rset = stmt.executeQuery ("select * from Test"
// Iterate through the result and print the employee names
while (rset.next ())
System.out.println (rset.getString (1));
}
}
错误提示:
Exception in thread "main" java.sql.SQLException: Io 异常: The Network Adapter c ould not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java :125)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java :162)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java :274)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:322)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java: 347)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:150)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio n.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:549)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at test.main(test.java:31)
给点建议呀!!作者: yaowu 时间: 2006-09-11 20:41
我已经找到原因了,没有打开监听进程!!!