2010-08-26 146 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" /> 
相关问题