通过 JDBC 瘦驱动程序连接 Oracle 11g 时出现问题 (Domino Java)

发布于 2024-09-15 18:03:01 字数 1377 浏览 2 评论 0原文

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

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 ?

( 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);
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眉黛浅 2024-09-22 18:03:01

好的,现在我可以连接了..以下是我尝试过的所有可能的连接字符串,并且都有效,

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"

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"
酷到爆炸 2024-09-22 18:03:01

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

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

Use this, syntax for JDBC URL for oracle 11 g has changed

<property name="url" value="jdbc:oracle:thin:@//localhost:1521/service_name" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文