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

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

Related

Quarkus + Hibernate + h2 - cannot create id

I'm using quarkus application with Postgres DB. For testing, I'm using h2 in-memory DB.
When I upgraded the version of hibernate to 5.6 I started facing issues with h2 tests. I found spring developers recommending hibernate.id.new_generator_mappings=false or set
#GeneratedValue(strategy = GenerationType.IDENTITY). The first thing does nothing if I put it in application.properties. The second thing helps for testing but now the application cannot generate an id (error like: cannot save id null).
When running tests:
Error executing DDL "create sequence hibernate_sequence start 1 increment 1" via JDBC Statement: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create sequence hibernate_sequence start 1 increment 1" via JDBC Statement
h2 configured as documented in quarkus.
%in-memory-profile.quarkus.datasource.db-kind = h2
%in-memory-profile.quarkus.datasource.jdbc.url = jdbc:h2:mem:test
It worked before upgrading quarkus and hibernate.

AWS Glue ETL MongoDB Connection String Error

Issue using MongoDb with AWS glue - I've created a connection to the database (using the MongoDb connection option) and run a crawler against it and it all worked fine, but when I try to use this as a datasource in a basic ETL job (script- Glue version 2.0Python version 3) it throws the exception
py4j.protocol.Py4JJavaError: An error occurred while calling o70.getDynamicFrame.
: java.lang.RuntimeException: Mongo/DocumentDB connection URL is not supported
Has anyone had any success using MongoDb as a datasource in glue ETL jobs?

Hibernate fail to register REF_CURSOR parameter

I am new to Hibernate. Using the 5.2.10 FINAL version connecting to Oracle 11g using the Oracle10gDialect with JPA 2.1 and ojdbc8.jar
I try to access a simple stored procedure taking a String input parameter and output a Oracle SYS_REFCURSOR.
StoredProcedureQuery call = session.createStoredProcedureCall("sp_get_profile");
call.registerStoredProcedureParameter(1, String.class, ParameterMode.IN);
call.registerStoredProcedureParameter(2, Class.class, ParameterMode.REF_CURSOR);
call.execute();
An exception occur when I access the function
ERROR SqlExceptionHelper Invalid column type: 2012
DatabaseException::error=[Error registering REF_CURSOR parameter [2]]
I try to write a simple program connecting to DB with the Oracle Driver only. I will have the same error if I register Types.REF_CUSOR as the output parameter to CallableStatement.
cs.registerOutParameter(2, Types.REF_CURSOR);
And the problem can be solved by changing to OracleTypes
cs.registerOutParameter(2, OracleTypes.CURSOR);
Anyone know what is wrong? I need to fall back to use the traditional SQL programming if I cannot get the stored procedure access success. . . please help.
Finally got it work, I should check the Oracle JDBC document first before implementation.
ojdbc8 should be good for Oracle 12c + JDK8 + JPA2.1 with Oracle12cDialect.
For Oracle 11g, need to use ojdbc6.jar
I solved that issue by debugging OJDBC and Hibernate, the building from sources a patched Hibernate CORE library (5.4.15-Final).
I have patched the method ExtractedDatabaseMetaDataImpl.supportsRefCursors which returns always false.

Bonita BPM could not execute statement

I'm trying to run a process in Bonita BPM 7.3 but get the following error when I click "Start" in the generated Instantiation form:
USERNAME=elh1u | org.bonitasoft.engine.persistence.SRetryableException: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
I tried changing the auto-generated form but it's not working either
Has anyone ever encountered this problem and how can it be solved ? Thank you
Hi lelh
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
PersistenceException Mean : you are try to overwrite persistanceid in some table
For Resolve : delete your previous data from database (Studio > Preference > Database > Tick Clear > Restart Studio )
ConstraintViolationException Mean : Maybe in some contract or constraint in humantask form level configured and you didn't respect it.
For Resolve : you need to send or respect it

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.