奇怪!!
mzer 2001-09-25 12:13:17 ORACLE难道和网卡有关系!!错误如下:
the network adapter could not establish the connection
JAVABEAN的代码如下:
package net.cnnic.midwest;
import java.io.*;
import java.sql.*;
import java.util.*;
public class ConnectionBean
{
private static Connection conn = null;
// The machine on which the database resides
public static String hostname="123.123.123.123";
// The TNS listener port
public static String port="1521";
// The database name (SID)
public static String dbSID="mian";
// The database User ID
public static String username="test";
// The database user password
public static String password="test";
public static Connection getConnection()
{
if (conn == null)
{
try
{
hostname=System.getProperty("s_hostName","123.123.123.123");
System.out.println("dbsid:"+hostname);
port=System.getProperty("s_tnsPort","1521");
dbSID=System.getProperty("s_databaseSID","main");
System.out.println("dbsid:"+dbSID);
username=System.getProperty("s_userName","test");
System.out.println("user:"+username);
password=System.getProperty("s_Password","test");
System.out.println("pass:"+password);
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:thin:@"+hostname+":"+port+":"+dbSID,username,password);
} catch(SQLException e)
{
e.printStackTrace();
return null;
}
}
return conn;
}
}