DB2连接授权Faliure出现原因:Java中不支持安全机制 [英] DB2 Connection Authorization Faliure Occured Reason: Security Mechanism not supported in Java

查看:432
本文介绍了DB2连接授权Faliure出现原因:Java中不支持安全机制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用DB2JDBC Type4驱动程序配置DB2连接。但是我收到这个错误。

I am trying to configure DB2 connection with DB2JDBC Type4 drivers. But I am getting this error.


线程main中的异常
com.ibm.db2.jcc.am.SqlInvalidAuthorizationSpecException :
[jcc] [t4] [201] [11237] [3.64.104]发生连接授权失败
。原因:不支持安全机制。 ERRORCODE = -4214,
SQLSTATE = 28000

Exception in thread "main" com.ibm.db2.jcc.am.SqlInvalidAuthorizationSpecException: [jcc][t4][201][11237][3.64.104] Connection authorization failure occurred. Reason: Security mechanism not supported. ERRORCODE=-4214, SQLSTATE=28000

我的代码是

public Connection getConnection() throws ClassNotFoundException, InstantiationException,
                                         IllegalAccessException, SQLException{

   Driver driver = (Driver) Class.forName ( "com.ibm.db2.jcc.DB2Driver" ).newInstance(); 
  DriverManager.registerDriver(driver);
  Connection  connection = DriverManager.getConnection("jdbc:db2://hostname:portnumber
                                           /DBName", "username","password" );
    System.out.println( "From DAO, connection obtained " );
    return connection;  
}

异常日志:

Exception in thread "main" com.ibm.db2.jcc.am.SqlInvalidAuthorizationSpecException:
[jcc][t4][201][11237][3.64.104] Connection authorization failure occurred. 
Reason: Security mechanism not supported. ERRORCODE=-4214, SQLSTATE=28000
    at com.ibm.db2.jcc.am.bd.a(bd.java:677)
    at com.ibm.db2.jcc.am.bd.a(bd.java:60)
    at com.ibm.db2.jcc.am.bd.a(bd.java:120)
    at com.ibm.db2.jcc.t4.b.f(b.java:2389)
    at com.ibm.db2.jcc.t4.b.a(b.java:1712)
    at com.ibm.db2.jcc.t4.y.b(y.java:3612)
    at com.ibm.db2.jcc.t4.y.a(y.java:477)
    at com.ibm.db2.jcc.t4.y.a(y.java:117)
    at com.ibm.db2.jcc.t4.b.c(b.java:1350)
    at com.ibm.db2.jcc.t4.b.b(b.java:1221)
    at com.ibm.db2.jcc.t4.b.b(b.java:788)
    at com.ibm.db2.jcc.t4.b.a(b.java:760)
    at com.ibm.db2.jcc.t4.b.a(b.java:421)
    at com.ibm.db2.jcc.t4.b.a(b.java:396)
    at com.ibm.db2.jcc.t4.b.<init>(b.java:334)
    at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:232)
    at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:198)
    at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:475)
    at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:116)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at com.test.connection.DB2ConnectionFactory.getConnection(DB2ConnectionFactory.java:19
    at com.test.connection.ConnectionTest.main(ConnectionTest.java:18)

我也尝试过这些支持的机制,由IBM Data Server Driver for JDBC和SQLJ

I also have tried these supported mechanisms by IBM Data Server Driver for JDBC and SQLJ

-CLIENT
-SERVER
-SERVER_ENCRYPT
-DATA_ENCRYPT
-KERBEROS
-GSSPLUGIN
-KRB_SERVER_ENCRYPT
-GSS_SERVER_ENCRYPT 

按顺序为了避免加密问题,我们已经将这个应用程序部署到了linux框中。如果需要安全连接,但在那里发生相同的错误。

In order to avoid encryption problem we have deployed this application to linux box. SO in case need secure connection, but same error is occurring there.

我正在使用DB2 JDBC驱动程序版本 v10.1fp1_jdbc_sqlj ,我也尝试过 9.5 9.1 db2jcc4.jar 文件为此目的。

I am using DB2 JDBC Driver version v10.1fp1_jdbc_sqlj, and I have also tried 9.5 and 9.1 and db2jcc4.jar file for this purpose.

我也尝试过使用类型2 驱动程序,但是在这种情况下我收到ClassNotFound错误 COM.ibm.db2.jdbc.app.DB2Driver 。没有找到类。

I have also tried it using type 2 drivers, but I am getting ClassNotFound error in that case COM.ibm.db2.jdbc.app.DB2Driver. class not found.

但到目前为止没有任何工作。任何帮助是赞赏。我在一个星期内一直在努力解决这个问题。

But nothing worked so far. Any help is appreciated. I am struggling with this problem over a week.

推荐答案

问题在于DB2。您必须确保您的环境变量指向正确的文件夹。因此,请确保执行以下操作:

It's working now. The problem was with DB2. You have to make sure that your environment variables point to the correct folders. So make sure to do the following:


  • 每次更改后或在对环境变量进行的所有更改后,都必须重新启动计算机。

  • 确保您使用的是 JDBC Type 2 驱动程序。不要去类型4 ,除非您的DBA要求。

  • Must reboot your machine after each change or after all the change you made to your environment variables.
  • Make sure that you are using JDBC Type 2 drivers. Do not go for Type 4 unless asked by your DBA.

将帮助您确保您的代码能够与Windows JDBC驱动程序交互

Will help you to make sure that your code will be able to interact with Windows JDBC Drivers

PATH=C:\Program Files\IBM\SQLLIB\BIN\db2jdbc.dll

LIB 将帮助您的代码阅读正确的库。即 COM.ibm.db2.jdbc.app.DB2Driver

LIB=;C:\PROGRA~1\IBM\SQLLIB\LIB

ClassPath: / p>

ClassPath:

ClassPath = .;C:\PROGRA~1\IBM\SQLLIB\java\db2java.jar;
C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;
C:\PROGRA~1\IBM\SQLLIB\BIN\db2jdbc.dll;
C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;
C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;
C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cu.jar;
C:\PROGRA~1\IBM\SQLLIB\java\db2java.jar;
C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\java\jdk;

这篇关于DB2连接授权Faliure出现原因:Java中不支持安全机制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆