Ecpiselink NativeQuery from other schema - jpa

i would execute a simple select with eclipselink from another schema like this:
Query query = em.createNativeQuery("select * from another_schema.TABLE_NAME");
List returnList = query.getResultList();
But when i run my application i get the following error:
java.sql.SQLException: The transaction is no longer active - status: 'Marked rollback.
Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: The transaction is no longer active - status: 'Marked rollback. [Reason=weblogic.transaction.internal.TimedOutException: Transaction timed out after 30 seconds
BEA1-0091256F3B0B87325B62]'. No further JDBC access is allowed within this transaction.
I have privileges to run this sql command, i tried with sql developer, and it's working.
Can anybody please help me, how should I run this NativeQuery?
Thank you!

I solved this error "No further JDBC access is allowed within this transaction." by setting the transaction in Weblogic as "Local Transaction".
Just uncheck the transaction option: Supports Global Transactions

Related

How to fix the DB calls exception - ERROR: Cannot execute INSERT in a read-only transaction in Spring boot JPA

I am facing the below error when doing insert/updates/deletes using Spring Boot -JPA
when executing the Postgres calls?
org.springframework.orm.jpa.JpaSystemException : could not execute statement ; nested exception is org.hibernate.exception.GenereircJDBCException : Could not execute statement with root cause org.postgreql.util.PSQLException: ERROR cannot execute INSERT in a read-only transaction
The application is kind of modeled along the lines as in
https://springframework.guru/how-to-configure-multiple-data-sources-in-a-spring-boot-application/
I am using the below stack
Spring boot - 2.2.7.RELEASE
JPA 2.0
This is a multidatasource application and i can't make any changes at the DB server.
Are there any changes that we can do at the java code end to fix the issue.
Regards

SQL0443 error when executing a Select with a Trigger on DB2 for iSeries

I've some problem querying a db2/as400 table, let's call it TAB1. Since it was added a trigger on this table when I perform a normal SELECT (using the TAB1-key) I get the following error. Never had a problem before the trigger was created.
It's a query performed in a batch-application (Java 1.6) using Modern Batch and Spring Batch 2.1.8. No chance to update the libraries, since the program is quite old and the customers won't agree.
Anyway,I would say it's a trigger problem ( as the sql codes say) but different applications perform different SELECTs on TAB1 and they never get any similar problem.The batch perform more or less 40000 select like this, and just 300 fail with this error.
Any idea, tip, suggestion?
### Error querying database. Cause: java.sql.SQLException: [SQL0443] *N *N
### The error may exist in class path resource [eu/mycompany/el20/dq/as400/dataaccess/mappers/tab1/Tab1Mapper.xml]
### The error may involve eu.mycompany.el20.dq.as400.dataaccess.persistence.tab.Tab1Mapper.selectByExample-Inline
### The error occurred while setting parameters
### SQL: select * from TAB1 WHERE ( D10_SOC = ? and D10_COD_NDG = ? and D10_DATE = ? )
### Cause: java.sql.SQLException: [SQL0443] *N *N
; uncategorized SQLException for SQL []; SQL state [38501]; error code [-443]; [SQL0443] *N *N; nested exception is java.sql.SQLException: [SQL0443] *N *Nstack trace: org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
com.sun.proxy.$Proxy120.selectList(Unknown Source)
org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:124)
org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:90)
org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
com.sun.proxy.$Proxy136.selectByExample(Unknown Source)
eu.mycompany.el20.dq.as400.crud.services.tab.BLSTab1.select(BLSTab1.java:46)
it.mycompany.xframe.dq.batch.steps.programstep.ProgramExecutor.processRecord(ProgramExecutor.java:544)
com.ibm.websphere.batch.devframework.steps.technologyadapters.GenericXDBatchStep.processRecord(GenericXDBatchStep.java:263)
com.ibm.websphere.batch.devframework.steps.technologyadapters.GenericXDBatchStep.processJobStep(GenericXDBatchStep.java:227)
com.ibm.ws.gridcontainer.batch.impl.StepManagerImpl._regularJobBatchLoop(StepManagerImpl.java:1065)
com.ibm.ws.gridcontainer.batch.impl.StepManagerImpl.executeStep(StepManagerImpl.java:390)
com.ibm.ws.gridcontainer.security.actions.ExecuteStepBatchUserPrivilegedAction.executeAction(ExecuteStepBatchUserPrivilegedAction.java:47)
com.ibm.ws.gridcontainer.security.AbstractUserPrivilegedAction.runWithoutSecurity(AbstractUserPrivilegedAction.java:66)
com.ibm.ws.gridcontainer.services.impl.WASRunUnderCredentialServiceImpl.runUnderUserCredential(WASRunUnderCredentialServiceImpl.java:134)
com.ibm.ws.gridcontainer.services.impl.WASRunUnderCredentialServiceImpl.runActionUnderUserCredential(WASRunUnderCredentialServiceImpl.java:386)
com.ibm.ws.gridcontainer.batch.impl.JobManagerImpl._sequentialStepScheduling(JobManagerImpl.java:783)
com.ibm.ws.gridcontainer.batch.impl.JobManagerImpl.executeJob(JobManagerImpl.java:199)
com.ibm.ws.batch.BatchJobControllerWork._runJob(BatchJobControllerWork.java:435)
com.ibm.ws.batch.BatchJobControllerWork.run(BatchJobControllerWork.java:241)
com.ibm.ws.asynchbeans.J2EEContext$RunProxy.run(J2EEContext.java:271)
java.security.AccessController.doPrivileged(AccessController.java:399)
com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:797)
com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:222)
com.ibm.ws.asynchbeans.ABWorkItemImpl.run(ABWorkItemImpl.java:206)
java.lang.Thread.run(Thread.java:790)
The text for message SQL0443 is 'Trigger program or external routine detected an error'.
I would suggest looking at the host database server job for the JDBC connection.
On the IBM i command line, run the command WRKOBJLCK OBJ(<user>) OBJTYPE(*USRPRF) (where <user> is the user profile you're using to do the JDBC connection) and find jobs named QZDASOINIT. These are the database host server jobs.
In these jobs, look at the joblog (or joblog spool file) to find the SQL0443 message ... around that message you should see what the actual error is.

postgresql pg_database_size throwing exception on random times

We are using Azure database for PostgreSQL ( Service ) for creating DB for each user when user register to the application ( less than 25 users databases right now ).
For reporting purpose we need information which each user's DB size.
To retrieve database size we have a Postgres function which fires the following query
SELECT pg_database.datname , pg_database_size(pg_database.datname) FROM
pg_database
We execute this function every hour throw azure function but at random time Postgres throw exceptions
Exception: Npgsql.PostgresException (0x80004005): 58P01: could not read directory "base/16452": No such file or directory at...
Exception remain same at most of the time with different directory or file location
Sometimes it also throws the exception
Exception: Npgsql.NpgsqlException (0x80004005): Exception while reading from stream ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException
Working on the solution at the MSDN forums here.

Powercenter SQL1224N error connecting DB2

Im running a workflow in powercenter that is constatnly getting an SQL1224N error.
This process execute a query against one table (POLIZA) with 800k rows, it retrieves the first 10k rows and then it start to execute to another table with 75M rows, at ths moment in DB2 an idle thread error appear but the PWC process still running retrieving the 75M rows, when it is completed (after 20 minutes) the errros comes up related with the first table:
[IBM][CLI Driver] SQL1224N A database agent could not be started to service a request, or was terminated as a result of a database system shutdown or a force command. SQLSTATE=55032
sqlstate = 40003
[IBM][CLI Driver] SQL1224N A database agent could not be started to service a request, or was terminated as a result of a database system shutdown or a force command. SQLSTATE=55032
sqlstate = 40003
Database driver error...
Function Name : Fetch
SQL Stmt : SELECT POLIZA.BSPOL_BSCODCIA, POLIZA.BSPOL_BSRAMOCO
FROM POLIZA
WHERE
EXA01.POLIZA.BSPOL_IDEMPR='0015' for read only with ur
Native error code = -1224
DB2 Fatal Error].
I have a similar process runing against the same 2 tables and it is woking fine where the only difference I can see is that the DB2 user is different.
Any idea how can i fix this?
Regards
The common causes for -1224 are:
Your instance or database has crashed, or
Something/somebody is forcing off your application (FORCE APPLICATION or equivalent)
As for the crash, I think you would know by know. This typically requires a database or instance restart. At any rate, can you please have a look into your DIAGPATH to check for any FODC* directories whose timestamp would match the timestamp of the -1224 errors?
As for the FORCE case, you should find some evidence of the -1224 in db2diag.log. Try searching for the decimal -1224, but also for its hex representation (0xFFFFFB38).

Unexpected token UNIQUE, requires COLLATION in statement [SET DATABASE UNIQUE])

Whenever I connect to HSQLDB from my application deployed on JBoss 5.1, it throws exception as : Caused by: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: error in script file line: 1 Unexpected token UNIQUE, requires COLLATION in statement [SET DATABASE UNIQUE]) .
My HSQLDB script file reads something as below :
`SET DATABASE UNIQUE NAME HSQLDB2E0BAD63B3
SET DATABASE GC 0
SET DATABASE DEFAULT RESULT MEMORY ROWS 0
SET DATABASE EVENT LOG LEVEL 0
.....`
Does anyone have idea what thos exception means or should I change something in my HSQLDB configuration?
Regards,
Satya
Your database files are created with version 2.x, but the version of database engine running on JBoss 5.1 is 1.8.x. You should be able to replace the hsqldb.jar in the JBoss configuration with a new version.