【发布时间】:2017-10-29 17:08:55
【问题描述】:
请在下面找到代码。我只能通过带有 ojdbc6.jar 的 jdk 6 获得连接。
在 jdk 7 和 8 中,我明白了,
网络适配器无法建立连接错误和连接 超时
远程 oracle 数据库在 Oracle 11g 上运行。
try {
Class.forName("oracle.jdbc.OracleDriver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your Oracle JDBC Driver?");
e.printStackTrace();
return;
}
System.out.println("Oracle JDBC Driver Registered!");
Connection connection = null;
try {
connection = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=abcd.efg)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=OW_DEF)))","user","pwd#");
} catch (SQLException e) {
System.out.println("Connection Failed! Check output console");
e.printStackTrace();
return;
}
if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
【问题讨论】:
-
您使用的是哪个版本的 Oracle JDBC 驱动程序(请完整版)
标签: java oracle jdbc oracle11g