title: DB2 Connection Authorization Faliure Occured Reason: Security Mechanism not supported in Java
body: <p>I am trying to configure DB2 connection with DB2JDBC Type4 drivers. But I am getting this error.</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>My code is </p>
  
  <pre><code>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;  
  }
  </code></pre>
  
  <p>Exception log:</p>
  
  <pre><code>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.&lt;init&gt;(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)
  </code></pre>
  
  <p>I also have tried these supported mechanisms by IBM Data Server Driver for JDBC and SQLJ</p>
  
  <pre><code>-CLIENT
  -SERVER
  -SERVER_ENCRYPT
  -DATA_ENCRYPT
  -KERBEROS
  -GSSPLUGIN
  -KRB_SERVER_ENCRYPT
  -GSS_SERVER_ENCRYPT 
  </code></pre>
  
  <p>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.</p>
  
  <p>I am using DB2 JDBC Driver version <code>v10.1fp1_jdbc_sqlj</code>, and I have also tried <code>9.5</code> and <code>9.1</code> and <code>db2jcc4.jar</code> file for this purpose. </p>
  
  <p>I have also tried it using <code>type 2</code> drivers, but I am getting ClassNotFound error in that case <code>COM.ibm.db2.jdbc.app.DB2Driver</code>. class not found.   </p>
  
  <p>But nothing worked so far. Any help is appreciated. I am struggling with this problem over a week.</p>