title: JDBC & Hiberntate Error in DB2 : Connection authorization failure occurred | SQL Error: -99999, SQLState: 42505
body: <p>Hello guys i tried to UPDATE a row in a DB2 table but i get a error</p>
  
  <pre><code>java.sql.SQLException: Connection authorization failure occurred.
  </code></pre>
  
  <p>In hibernate I have this:</p>
  
  <pre><code>    StringBuilder sb = new StringBuilder();
  
      sb.append("UPDATE Scsret set pollife = 'x' ");
      sb.append("WHERE id = 68197");// test dummy update
  
      Query query = getCurrentSession().createQuery(sb.toString());
  
      int update = query.executeUpdate();
  </code></pre>
  
  <p>And get this error</p>
  
  <pre><code>WARN : org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: -99999, SQLState: 42505
  ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Connection authorization failure occurred.
  org.hibernate.exception.SQLGrammarException: could not prepare statement
      at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122)
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
      at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:188)
      at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:91)
      at org.hibernate.hql.internal.ast.exec.BasicExecutor.execute(BasicExecutor.java:90)
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:413)
      at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:282)
  ...
  Caused by: java.sql.SQLException: Connection authorization failure occurred.
      at com.ibm.as400.access.JDError.throwSQLException(JDError.java:405)
      at com.ibm.as400.access.AS400JDBCConnection.checkAccess(AS400JDBCConnection.java:388)
      at com.ibm.as400.access.AS400JDBCStatement.commonPrepare(AS400JDBCStatement.java:1149)
      at com.ibm.as400.access.AS400JDBCPreparedStatement.&lt;init&gt;(AS400JDBCPreparedStatement.java:248)
  </code></pre>
  
  <p>And i tried also using Pure Jdbc, but i get the same</p>
  
  <pre><code>    StringBuilder sb = new StringBuilder();
  
      sb.append("UPDATE LSMODDTA.SCSRET SET FEMI  = 20140102 WHERE ID = ");
      sb.append("68196"); //test dummy update
  
      try {
          PreparedStatement  preparedStatement = conn.prepareStatement(sb.toString());
  
          int update = preparedStatement.executeUpdate();
  
          System.out.println(update);
  
  
  
          //System.out.println(update);
      } catch (SQLException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>And produce this error</p>
  
  <pre><code> java.sql.SQLException: Connection authorization failure occurred.
      at com.ibm.as400.access.JDError.throwSQLException(JDError.java:405)
      at com.ibm.as400.access.AS400JDBCConnection.checkAccess(AS400JDBCConnection.java:388)
      at com.ibm.as400.access.AS400JDBCStatement.commonPrepare(AS400JDBCStatement.java:1149)
      at com.ibm.as400.access.AS400JDBCPreparedStatement.&lt;init&gt;(AS400JDBCPreparedStatement.java:248)
      at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:2088)
      at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1887)
  </code></pre>
  
  <p>In SQL editor run the query that generated Hibernate, and work perfect</p>
  
  <pre><code>update
          LSMODDTA.SCSRET 
  set
          pollife='x' 
  where
          id=68196
  </code></pre>
  
  <p><strong>Both connections have the same user</strong> </p>
  
  <p>What's going on?</p>