我无法使用以下代码远程连接 Oracle 11 数据库。但是,如果我尝试连接安装在我的计算机上的 Oracle 9 数据库,相同的代码可以正常工作。缺什么 ?
(我没有收到任何错误,Lotus Notes 挂起)
import lotus.domino.*;
import java.sql.*;
import oracle.jdbc.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
//Calling connection method
Connection conn= getOracleConnection(db);
if(conn!=null){
System.out.println("Connected..");
}
else {
System.out.println("There is a problem in connecting database..");
System.exit(0);
}
} catch(Exception e) {
e.printStackTrace();
System.exit(0);
}
}
private static Connection getOracleConnection(Database db) throws Exception {
// Register driver
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
//Retrieving connection string from profile document.
String host = "SPRPRG020.int.server.com";
String ip = "1521";
String user = "system";
String password = "password";
String sid = "XE";
String url="jdbc:oracle:thin:@"+host+":"+ip+":"+sid;
return DriverManager.getConnection(url, user, password);
}
}
好吧,伙计们,现在我可以连接了..以下是我尝试过的所有可能的连接字符串,并且全部有效,
1- "jdbc:oracle:thin:@server.cgg.com:1569:ServiceName"
2- "jdbc:oracle:thin:@//server.cgg.com:1569/ServiceName"
3- "jdbc:oracle:thin:@server.cgg.com:1569/ServiceName"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)