我使用cat5交叉以太网电缆连接了两台笔记本电脑。两个都安装了linux ubuntu。两台Linux计算机上的Oracle jdbc连接
Lappi 1: $ ifconfig eth0 192.168.1.16 up
Lappi 2: $ ifconfig eth0 192.168.1.17 up
都经由有线以太网连接
ping lappi 1: $ ping 192.168.1.17
give bytes means working
ping lappi 2: $ ping 192.168.1.16
working
lappi 1具有安装在其上的Oracle XE10克。
我想从lappi-1的oracle数据库中使用lappi-2获取一些行。
这里是代码
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class servertest
{
public void test() throws ClassNotFoundException, SQLException
{
Class.forName ("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@192.168.1.16:1521:XE","scott","tiger");
Statement stmt = conn.createStatement();
String query = "select email_to from createemail";
ResultSet rset = stmt.executeQuery(query);
while(rset.next())
{
System.out.println(rset.getString(0));
}
}
public static void main(String args[]) throws ClassNotFoundException, SQLException
{
servertest obj = new servertest();
obj.test();
}
}
它不给我任何错误。但它也不会检索任何行。有时我会收到错误“连接无法建立”...(偶尔)]