各位大侠帮忙: 使用JDBC连接Oracle9i,特别简单的代码:
package copyciw;import oracle.jdbc.OracleDriver;
import java.sql.*;
public class ADO
{
static String driverName="oracle.jdbc.OracleDriver";
static String url01="jdbc:oracle:thin:@210.30.108.5:1521:oracle01";
static String url03="jdbc:oracle:thin:@202.118.65.31:1521:oracle03";
static String userName="ciw";
static String userPassword="cityciw";
public ADO()
{
}
//
public static Connection getConnection01() throws Exception
{
Connection cn=null;
//
Class.forName(driverName);
cn=DriverManager.getConnection(url01,userName,userPassword); //
return cn;
}
//
public static Connection getConnection03() throws Exception
{
Connection cn=null;
Class.forName(driverName);
System.out.println("T01");
cn=DriverManager.getConnection(url03,userName,userPassword);
System.out.println("T02");
return cn;
}
//}T01和T02之间的连接有错误。
结果如下:
T01Error:Io 异常: NL Exception was generated不知道这是什么异常?
package copyciw;import oracle.jdbc.OracleDriver;
import java.sql.*;
public class ADO
{
static String driverName="oracle.jdbc.OracleDriver";
static String url01="jdbc:oracle:thin:@210.30.108.5:1521:oracle01";
static String url03="jdbc:oracle:thin:@202.118.65.31:1521:oracle03";
static String userName="ciw";
static String userPassword="cityciw";
public ADO()
{
}
//
public static Connection getConnection01() throws Exception
{
Connection cn=null;
//
Class.forName(driverName);
cn=DriverManager.getConnection(url01,userName,userPassword); //
return cn;
}
//
public static Connection getConnection03() throws Exception
{
Connection cn=null;
Class.forName(driverName);
System.out.println("T01");
cn=DriverManager.getConnection(url03,userName,userPassword);
System.out.println("T02");
return cn;
}
//}T01和T02之间的连接有错误。
结果如下:
T01Error:Io 异常: NL Exception was generated不知道这是什么异常?
try{
cn=DriverManager.getConnection(url01,userName,userPassword); cn=DriverManager.getConnection(url03,userName,userPassword);}catch(Exception exc){
........
}