简体   繁体   English

通过oracle直接连接到db2数据库时连接,但是通过java代码连接时抛出异常

[英]while connecting directly to the db2 database thru oracle it connects but when connected thru java code throws exception

Hi I am getting below exception when i try to connect DB2 server thru java 嗨,当我尝试通过Java连接DB2服务器时,出现以下异常

com.ibm.db2.jcc.b.ao: [jcc][t4][2010][11246][3.53.70] Connection authorization failure occurred. com.ibm.db2.jcc.b.ao:[jcc] [t4] [2010] [11246] [3.53.70]发生连接授权失败。 Reason: Local security service non-retryable error. 原因:本地安全服务不可重试错误。 ERRORCODE=-4214, SQLSTATE=28000 错误代码= -4214,SQLSTATE = 28000

When I tried connecting the DB2 using SQL Developer (With jars added in Third Party tool) the connection was successful. 当我尝试使用SQL Developer(在第三方工具中添加了jar)连接DB2时,连接成功。 I included all the required db2jcc,db2jcc4 and db2jcc_license jar files in the project. 我在项目中包含了所有必需的db2jcc,db2jcc4和db2jcc_license jar文件。 But it throws exception. 但这会引发异常。

try{
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    String url = "jdbc:db2://myhost:portNumber/dbname";                
    Connection con = DriverManager.getConnection(url, "uname","password"); 
}catch(Exception e){
    e.printStackTrace();
}

3.53.70 driver version corresponds to quite an old 9.5.3 db2 version. 3.53.70驱动程序版本与相当老的9.5.3 db2版本相对应。 You should try to download a jdbc driver corresponding to your db2 version. 您应该尝试下载与您的db2版本相对应的jdbc驱动程序。 DB2 JDBC Driver Versions and Downloads DB2 JDBC驱动程序版本和下载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM