SQL Error: -1, SQLState: 08000 not flushing record - java

Technical background: Groovy 2.5.6 using Java 8. MariaDb database.
Background: I have a report system in place. Different Reports are added to a database table. A job executes every 15 minutes and puts a report into a "In progress" state from a "New" state. Then once the job successfully executes the report is updated to a "Done" state. If any exceptions occur the report will put into a "Error" state.
The problem is that once the job executes the report fails to save. In the logs I can see I get a SQL Error: -1, SQLState: 08000 and (conn=64796) Socket error. This indicated to me that there is a connection issue with the database. This is followed with SQL Error: 1220, SQLState: 08000.
There is a problem with the database connection, which has already been closed. The application is failing to generate a report and update a record.
I put the report again in a "New" state and let the job re-run. The same issue occured again. So I was able to replicate it. I do not really have a clear method to follow to troubleshoot.
How do I resolve this error? Is this related to Java 8?

Related

Stored Procedure call from Java returning SQLException after PLSQL code changes

I am calling a Stored Procedure using JDBC and the connection is configured as UCP in Oracle Web Logic Server 12c. Below is my sample code snippet.
String query = "{? = call PACK_GLOBAL_VARIABLES.getBatchDate()};
CallableStatement cs = connection.prepareCall(query);
cs.registerOutParameter(1, Types.DATE);
cs.executeUpdate();
The problem is, whenever there is any code change at PL/SQL end then I am always getting this exception:
java.sql.SQLException: ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "SJN_UAT.PACK_GLOBAL_VARIABLES" has been invalidated
ORA-04065: not executed, altered or dropped package body "SJN_UAT.PACK_GLOBAL_VARIABLES"
ORA-06508: PL/SQL: could not find program unit being called: "SJN_UAT.PACK_GLOBAL_VARIABLES"
ORA-06512: at line 1
This issue gets resolved by means of either of these 2 ways:
Restart the Web Logic Server
Compile the PL/SQL package multiple times (without restarting Web Logic)
None of the above two approaches are feasible in Production environment.
Can anyone please help in identifying this issue and the possible resolution?
it is not a good practice to rebuild package when the applcation is running.
it seems the expected behavior of oracle and java application.
two possible soluation:
alter system flush shared pool after rebuild package, have protential risk about database
catch error code in java code, if the error code is 4068, reexecute the package

Java JDBC executeUpdate not working on Delete SQL with TRUNC function in where clause

The following delete statement is working fine in SQL developer but when executed using JDBC api executeUpdate() is not working.
After removing the where clause its working fine.
Delete from Tab1
where TRUNC(CREATED_TS) <= TRUNC(ADD_MONTHS(SYSDATE,-3))
I am not able to figure out the problem as no exception or error is printed.Only code execution is getting hanged at the executeUpdate() method.
Database : Oracle 11g
Java: 1.6
Since there is no Exception or Stack Trace one can only guess.
Probably the Exception is being swallowed in the Java code. Have a look at that and Print it if possible.
where TRUNC(CREATED_TS) <= TRUNC(ADD_MONTHS(SYSDATE,-3)) will prevent index on CREATED_TS (if there was one) from being used and may slow down the process. And a timeout may have occurred. I would check the connection/statement timeout settings on the Java side of the setup.
The issue was not with the delete SQL.The issue was with another session in which there was some uncommitted changes.Because of that the delete SQL from java code was getting hanged indefinitely. On issuing a commit on the another session ,java api executeUpdate() responded and it started working fine.
The question is similar to the issue as in the below link:
Oracle database is hanging infinitly in UPDATE queries

Getting CmisUnauthorizedException: Unauthorized error while iterating Query Result

I am able to successfully establish a connection between my java based app and SharePoint 2013 using CMIS. Everything works fine. I am running a CMIS Query. The first time the session is created and I run the query it works fine.
But when I run the same query second time using the already created session, it gives me "Unauthorized" error. I have also verified the same using a standalone Java program . Everytime I create a fresh session and run the query. Then it works.
I am getting this exception randomly.
Hope someone could help me solving this. Thanks!
Exception trace :Exception trace : (At the line when I try to perform any kind of operation on query result (even if I try to get the total number of items in query result))
org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException: Unauthorized
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:460)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:629)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.DiscoveryServiceImpl.query(DiscoveryServiceImpl.java:145)
at org.apache.chemistry.opencmis.client.runtime.SessionImpl$3.fetchPage(SessionImpl.java:600)
at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.getCurrentPage(AbstractIterator.java:132)
at org.apache.chemistry.opencmis.client.runtime.util.CollectionIterator.hasNext(CollectionIterator.java:48)
May be the session is getting expired. Check the session time out. Try re-creating the session when you receive the exception

locked by transaction: #console:Oracle (INTELLIJ CLIENT)

I am working on IntelliJ IDEA 14.1.4, Recently we connected database to the Client and it was working okay, until some recent times when we start getting error
[2015-09-28 10:12:55] locked by transaction: #console:Oracle - <<DBName>>#localhost
Now we can't perform any transaction as we keep getting the same error. We tried googling the error but could not find anything to solve the problem. Any help would be appreciated!!!
I had this happen after a previous query I ran failed -- using PyCharm, not IntelliJ, but it is the same JetBrains system. I did not have Auto-commit turned on. Pycharm couldn't recover from the failed query for some reason, and it left an unresolved transaction active in the database. I disconnected from the database (hit the red stop button in the database window), and then I was able to resume with new queries with no problem. You might also try the rollback button at the top of the window with your SQL statements if reconnecting would cause you problems.
Putting up answer for the same comment.
I think there should be some row lock on the DB. if you have an Oracle DBA, check out for table/row lock. It can happen if the transaction exception occurred and rollback didn't happen properly or a transaction is still open for a longer time.
You can execute the following query to check for the same if transaction is pending.
SELECT COUNT(*)
FROM v$transaction t, v$session s, v$mystat m
WHERE t.ses_addr = s.saddr
AND s.sid = m.sid;
Additional resources :
Oracle: How to find out if there is a transaction pending?
How to find locked rows in Oracle
Consult with your DBA after your initial research. I'm not aware about releasing locks.

flyway commandline tool - what option to re-execute failed DDL?

I successfully ran v1 migration with a create table DDL. I copied same to v2 file and ran - got the expected validation error message:
Migrating to version 1.0.002
com.googlecode.flyway.core.exception.FlywayException: Error executing statement
at line 1: create table people(id number(10) primary key, name varchar2(301))
Caused by java.sql.SQLSyntaxErrorException: ORA-00955: name is already used by a
n existing object
MigrationException: Migration to version 1.0.002 failed! Please restore backups
and roll back database and code
I corrected the v2 file and ran flyway migrate again. Giving back the error message
Current schema version: 1.0.002
MigrationException: Migration to version 1.0.002 failed! Please restore backups
and roll back database and code
I am not in a stage where a database backup is taken - simple trying to execute a fixed DDL. I don't currently see a solution short of flyway clean. Why cannot flyway try to execute FAILED versions again (if the checksum has changed)? Or shouldn't there be a flyway rollback command?
I know I can very well modify the code to make it that way, but was there any reason why you chose it to behave this way?
The problem with simply reexecuting is that some changes might already have been applied, which will cause the migration to fail.
There are two solutions to this:
Use a database that supports DDL transactions such as PostgreSQL, SQLServer or DB2
Perform a manual cleanup of the modified structures and the metadata table before reapplying

Categories

Resources