通过JDBC瘦驱动程序(Domino Java)连接Oracle 11g时出现问题 [英] Problem in connecting Oracle 11g through JDBC thin driver ( Domino Java )
本文介绍了通过JDBC瘦驱动程序(Domino Java)连接Oracle 11g时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法使用以下代码远程连接Oracle 11数据库。但是,如果我尝试连接安装在我的计算机上的Oracle 9数据库,相同的代码工作正常。缺少什么?
I'm unable to connect Oracle 11 database remotely using following piece of code. However, same code works fine if I try to connect Oracle 9 database which is installed on my machine. What is missing ?
(我没有收到任何错误,Lotus Notes挂起)
( I'm not getting any error, Lotus Notes hangs )
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);
}
}
推荐答案
确定伙计们,现在我能够连接..以下是我尝试过的所有可能的连接字符串,并且一切正常,
OK Guys, Now I'm able to connect.. Here are all possible connection string I've tried and all works,
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"
这篇关于通过JDBC瘦驱动程序(Domino Java)连接Oracle 11g时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文