Hibernate unable to retrieve resultSet in production environment - java

I'm having trouble identifying the issue with Hibernate where Hibernate throws persistence exception.
I've include a screenshot of the code.Sorry regarding the censoring. Source Code
Added logs as per Christian's suggestion. Application logs
The following are findings which I've done to identify the problem
Production
Application logs show the following error (javax.persistence.PersistenceException:
org.hibernate.exception.SQLGrammarException: could not extract
ResultSet Application exception overridden by commit exception) Where
it manages to enter the DAO function but it doesn't show the Hibernate
query in logs,also fail to exit function. Ran the same source code
query in production using SQL and it returned expected results.
Just to clarify: There's another DAO function which uses the same
tables and it manages to display correctly on production so I doubt it would be a table grant issue
Development
Records from the query display correctly on front - end when queried
data is present, logs show that it manages to enter and exit the DAO
function with the query displayed. No error even when there are no
results in database table to retrieve (Logs show the Hibernate query, front-end has no results)

You are not showing the exact error details so it's hard to help. I guess you are setting some parameter to null maybe which Oracle can't handle or maybe one of the functions you are using can't handle the data. The error details you are logging should help you get to the bottom of this.

Related

H2 database with corrupted table

We have an H2 database with what looks to be a corrupted table. Using the H2 web console, we are able to run SELECT * queries on all the tables except one. For this one table, TBL_TRANSACTION, we get the error result:
SELECT * FROM TBL_TRANSACTION;
General error: "java.nio.BufferUnderflowException"; SQL statement:
SELECT * FROM TBL_TRANSACTION [50000-190] HY000/50000
When we run the H2 Recover tool, we get the following:
java -cp h2-1.4.190.jar org.h2.tools.Recover
Error: java.nio.BufferUnderflowException
The Recover tool does generate the h2.sql and the mv.txt file. However, after all the CREATE and INSERT statements, the h2.sql ends with
// error: java.nio.BufferUnderflowException
Running RunScript against this h2.sql file does recover a part of the corrupted table, but only a very small part (only up to the part where the BufferUnderFlowException occurred.)
Questions:
What could have happened to cause this corruption?
What steps can we take to recover the data?
Thanks in advance.

how to get a user confirmation in the middle of a transaction?

I've been working on a transactional services which is used as a part of core banking project. In many services, before inserting any records in my database, I should run several validation on the records. It is also true for editing the records which are already exist in the database.
But sometimes in order to update a record in an specified table, we should change records in other tables which are related to the specified table. Consequently, we need a user confirmation to change records on other tables. But the problem is I don't know how could I get a user confirmation in client while I run a transaction in the server. Is it possible to tackle this problem using sending message between client and server through rabbitMq?
I will be appreciate if any one explain any solution using clear sample.
When I would need to implement this, I would do it in an other way (I do not know if this works for your scenario).
I would first let the user input his data,
then I would do a try run and check which additional confirmations are needed I would also save (in the user session) all relevant constraints that are determined while the try run
then I would ask the user for the additional confirmations determined while the try run
then I would do the real-run, and use the saved constraint checks to be save that nothing relevant has been changed meanwhile.
(If there is a relevant change in the data between try- and real-rung detected, I would apologise and start the process with step 2 again)
but this only works if you do not have so many "meanwhile changes"

Find last query executed time in sql and mysql and pgsql from java

I'm in the need of last query executed time in mysql/sql/pgsql using query ... How can I get it?
MySql generates a log of logs including query log. Take a look here for details where the log is located and how to configure it. Now you can open the file and find any query including the last one.

JasperServer Error - Unable to get next record

I have a very simple report that runs perfectly on in iReports (4.5.0) on my workstation. When I upload it JasperServer CE (4.5.0) I get the following error.
1 - Unable to get next record.
java.lang.Exception: 1 - Unable to get next record.
at com.jaspersoft.ireport.jasperserver.ws.WSClient.runReport(WSClient.java:403)
at com.jaspersoft.ireport.jasperserver.ws.WSClient.runReport(WSClient.java:320)
at com.jaspersoft.ireport.jasperserver.ReportRunner.run(ReportRunner.java:70)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
There are other much more complex queries and reports that are running on the JasperServer without problem. The database system is Basis/Pro5 running BBJ (Business Basic Java). I am connected to the database in iReports and JasperServer using the same native JDBC Basis driver (BBjJDBS.jar). JasperServer is running on the same RHEL box as the BBj database. Jasper server is installed as a bundle using both the built in DB and Tomcat. No other known conflicts exist.
The following single table query is designed to get the sum totals of a transaction for a given month. The report has one detail section which just prints the query output.
SELECT
Month(INHI.TRANSACTION_DATE) AS TransMonth,
admin.INHI.ITEM_ID,
admin.INHI.TRANSACTION_TYPE,
SUM(admin.INHI.TRANS_QUANTITY) as TransQty
FROM
admin.INHI
WHERE
admin.INHI.ITEM_ID = 'R-CBSH-3300'
AND (
admin.INHI.TRANSACTION_TYPE = 'B2'
OR admin.INHI.TRANSACTION_TYPE = 'P1')
AND admin.INHI.TRANSACTION_DATE BETWEEN '2012-01-01' AND '2012-03-31'
GROUP BY
Month(INHI.TRANSACTION_DATE),
admin.INHI.ITEM_ID,
admin.INHI.TRANSACTION_TYPE
Order By
admin.INHI.TRANSACTION_TYPE
I have looked all over to try and find additional trouble shooting tips and have ran out of options to try. Any guidance is greatly appreciated.
In my case I was able to get an extended error from the JasperServer web interface which lead me to an Date/Time issue. The crux of the whole problem was the "Order By" clause. Once I removed the order by the query worked fine.
You can also get this error if you pass a closed result set as the data source for the report.
In my case I passed the JasperReportBuilder object around and somewhere I (prematurely) closed the Connection object that the result set was bound to.

HSQLDB - hiding database structure/contents from users

I'm considering using HSQLDB version 1.8.x in a desktop app for storing local data. From what I can see, the database is stored on disk as a number of SQL statements to create the tables, insert the data, etc.
Is there a simple way I can hide this from users? I'm don't necessarily need it to be completely encrypted, etc - I'd just like to prevent the casual user from simply opening the file and seeing the structure of the database.
You could embed your database files within a jar file and connect to them using the notation:
jdbc:hsqldb:res:<path in jar>
Check out the Advanced Topics section of the HSQLDB guide for more information on this. However, I've never tried it so am not 100% sure it will work ...
The solution I've gone with for now is to call:
db.update("SET SCRIPTFORMAT COMPRESSED;");
to store the .script file in a human-unreadable form and:
db.update("SET PASSWORD password;");
to prevent more savvy users from opening the DB using their own HSQLDB client.
Unfortunately I was not able to execute below command
db.update("SET scriptformat COMPRESSED");
And was getting this error
java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: SCRIPTFORMAT
This error solved with this command
db.update("SET FILES SCRIPT FORMAT COMPRESSED");
I am using HSQLDB 2.3.3

Categories

Resources