Reputation: 750
Hello guys i tried to UPDATE a row in a DB2 table but i get a error
java.sql.SQLException: Connection authorization failure occurred.
In hibernate I have this:
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();
And get this error
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.<init>(AS400JDBCPreparedStatement.java:248)
And i tried also using Pure Jdbc, but i get the same
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();
}
And produce this error
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.<init>(AS400JDBCPreparedStatement.java:248)
at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:2088)
at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1887)
In SQL editor run the query that generated Hibernate, and work perfect
update
LSMODDTA.SCSRET
set
pollife='x'
where
id=68196
Both connections have the same user
What's going on?
Upvotes: 0
Views: 1685
Reputation: 26
This problem can be caused when the established connection is set as "readOnly" (Read more at: http://www-01.ibm.com/support/docview.wss?uid=nas8N1016865).
You could solve this by explicitly setting to FALSE the readOnly flag of your connection:
connection.setReadOnly(false);
Upvotes: 1