2010-08-26 139 views
2

我無法使用以下代碼段遠程連接Oracle 11數據庫。但是,如果我嘗試連接安裝在我的機器上的Oracle 9數據庫,相同的代碼工作正常。什麼不見​​了 ?通過JDBC瘦驅動程序連接Oracle 11g時出現問題(Domino Java)

(我沒有得到任何錯誤,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); 
    } 
} 
+0

如果您在調試器中逐步執行代碼,您是否碰巧遇到執行掛起該線程的行? – 2010-08-26 09:51:53

+0

@Vineet,無法這樣做,代碼凍結Lotus Notes。 – Rishi 2010-08-26 09:58:37

+0

此外,我認爲使用瘦驅動程序連接遠程Oracle數據庫沒有任何問題。我懷疑連接字符串中的語法錯誤。 – Rishi 2010-08-26 10:02:58

回答

1

我這篇文章後前一陣迷迷糊糊的,不妨一試:Oracle SID != SERVICE_NAME

+0

/加里,現在我試圖在Eclipse和 「找不到合適的驅動程序」錯誤。任何想法Oracle 11g的正確JDBC驅動程序是什麼?我試過ojdbc6.jar和ojdbc5.jar,但沒有成功。 – Rishi 2010-08-27 06:39:30

+0

在任何人不想將此標記爲僅鏈接之前,顯然它不是。 – pnuts 2014-09-12 19:36:42

2

OK夥計們,現在我能夠連接..這裏是所有可能的連接字符串我已經試過所有作品,

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" 
0

使用此,語法JDBC URL的是Oracle 11 g已經改變

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