【问题标题】:Problem in connecting Oracle 11g through JDBC thin driver ( Domino Java )通过 JDBC 瘦驱动程序 (Domino Java) 连接 Oracle 11g 时出现问题
【发布时间】:2011-04-04 04:24:59
【问题描述】:

我无法使用以下代码远程连接 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);
  }
}

【问题讨论】:

  • 如果您在调试器中单步执行代码,您是否会碰巧遇到执行挂起线程的行?
  • @Vineet,无法这样做,代码冻结了 Lotus Notes。
  • 另外,我认为使用瘦驱动程序连接远程 Oracle 数据库没有任何问题。我怀疑我的连接字符串中有语法错误。
  • 挂起可能正在等待网络响应。你能 ping SPPRRG020.int.server.com 吗?如果是这样,您可以在端口 1521 上远程登录到 SPPRRG020.int.server.com 吗?或者,您可以通过即时客户端中的 SQL*Plus 之类的东西进行连接吗?

标签: java jdbc lotus-notes oracle11g


【解决方案1】:

好的,伙计们,现在我可以连接了。这是我尝试过的所有可能的连接字符串,并且一切正常,

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"

【讨论】:

    【解决方案2】:

    使用这个,oracle 11g 的 JDBC URL 的语法已经改变

    <property name="url" value="jdbc:oracle:thin:@//localhost:1521/service_name" />
    

    【讨论】:

      猜你喜欢
      • 2012-11-20
      • 2013-11-05
      • 1970-01-01
      • 2013-09-29
      • 2011-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多