hibernate generated sql query changes characters improperly - oracle

DBMS - oracle 11gr2
we recently upgraded the IDE and OS of a java console application that runs 10 times a month.
now None of our queries work properly since hibernate converts the letter i to İ which is not I. All insert statements and id fields affected negatively.
now in our queries
id -> İD not ID
insert -> İNSERT not INSERT
neither select statements nor inserts do not execute.
for example:
in the previous version Select id from table a is now sent to the db as
SELECT İD from table a ,
and we dont have such a column called İD at all.
stack trace is as follows
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00904: "İD": geçersiz belirleyici (invalid identifier)
Query: ReadObjectQuery(name="readObject" referenceClass=OrtakEntity sql="SELECT İD, ADİ, ALACAKLARİNDAHACİZVARMİ, ANNEADİ, FROM A WHERE (İD = ?)")
********************sistem toplam sure***********************0.0
********************Time unit toplam sure***********************0
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00904: "İD": geçersiz belirleyici
Error Code: 904
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:684)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:526)
at org.eclipse.persistence.internal.session

I resolved the issue by changing the settings of the computer to English and United States as location. (still not the best approach but now the program runs)

Related

Big bug in Oracle JDBC driver for mixed-case table/column names?

This seems rather surprising, but I'm pretty sure we have found a significant bug in Oracle's JDBC driver (versions 12.1.0.2 and 11.2.0.4). Here's the schema:
create sequence MYSEQ increment by 1 start with 1 nocache;
create table "MixedCaseTable"(IDENT int);
Here's the Java code:
conn.prepareStatement("insert into \"MixedCaseTable\" " +
"(IDENT) VALUES (MYSEQ.nextval)",
new int[]{1});
Much to my surprise, this throws an exception:
Exception in thread "main" java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:459)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:392)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:384)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:767)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:539)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:235)
at oracle.jdbc.driver.T4C8Odscrarr.doODNY(T4C8Odscrarr.java:96)
at oracle.jdbc.driver.T4CConnection.doDescribeTable(T4CConnection.java:7555)
at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:12886)
at PStest.main(PStest.java:11)
If I use a different flavor of prepareStatement:
conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
that works fine.
If the table name is all caps (MYTABLE or even "MYTABLE"), that also works fine.
This problem can be reproduced without a sequence, e.g.:
conn.prepareStatement("insert into \"MixedCaseTable\" " +
"(IDENT) VALUES (1)",
new int[]{1});
This would mean that this flavor of prepareStatement is completely broken for all tables names and column names that are not all caps -- any names that need to be quoted.
Now, I didn't decompile Oracle's driver because that would presumably be illegal or something, but I have a friend who told me that he traced this problem down to the JDBC driver - class AutoKeyInfo, method getTableName, and the problem has to do with forcing the SQL to all caps for everything.
The workaround would consist of using the other version of prepareStatement (with Statement.RETURN_GENERATED_KEYS), get the ROWID, and then retrieve the row from that, but that's an extra query, and that just seems asinine.
Am I missing something? Surely a bug this big could not have been around for years?

How to solve : SQL Error: ORA-00604: error occurred at recursive SQL level 1

When I'm trying to drop table then I'm getting error
SQL Error: ORA-00604: error occurred at recursive SQL level 2
ORA-01422: exact fetch returns more than requested number of rows
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
One possible explanation is a database trigger that fires for each DROP TABLE statement. To find the trigger, query the _TRIGGERS dictionary views:
select * from all_triggers
where trigger_type in ('AFTER EVENT', 'BEFORE EVENT')
disable any suspicious trigger with
alter trigger <trigger_name> disable;
and try re-running your DROP TABLE statement
I noticed following line from error.
exact fetch returns more than requested number of rows
That means Oracle was expecting one row but It was getting multiple rows. And, only dual table has that characteristic, which returns only one row.
Later I recall, I have done few changes in dual table and when I executed dual table. Then found multiple rows.
So, I truncated dual table and inserted only row which X value. And, everything working fine.
I know the post is old and solved, but maybe someone is facing or will face my situation, so I want to leave the aquired knowledge here, after deal with the error for a week. I was facing the error: "ORA-00604: error occurred at recursive SQL level 1" , but with the internal error: " ORA-06502: error: character string buffer too smal numeric or value", this happened only when I try to logon the database, and using an specific driver, trying to connect from an Visual Studio C# application, the weirdest thing on that moment was that I connect from SQLDeveloper or TOAD and everything worked fine.
Later I discovered that my machine name had this format "guillermo-aX474b5", then I proceed to rename it like this "guillermo" without the "-" and the other stuff, and it worked!! Looks like in some drivers and situations, ORACLE Database does'nt like the "-" in the LogOn connection.
Hope it helps!

Error running SQL queries with Liquibase

I'm using Liquibase to create tables in DB2. I have a simple example changelog that tries to drop and then create a table.
The SQL statements work fine via my DbVisualizer tool (which uses the same JDBC driver as Liquibase) and also works fine when submitted via the db2 command line tool.
Here's the Liquibase input file:
--changeset dank:1 runAlways=true failOnError:false
DROP TABLE AAA_SCHEMA.FOO
--changeset dank:2 runAlways=true
CREATE TABLE AAA_SCHEMA.FOO ( MYID INTEGER NOT NULL )
Here's the error message I get:
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error:
SQLCODE=-104, SQLSTATE=42601, SQLERRMC=DROP TABLE AAA_SCHEMA.FOO;
;, DRIVER=4.18.60
The IBM error code -104 is about syntax problems. Based on looking at the error message my guess is that it has something to do with the end of line character ";". But I've tried the query with and without the semi-colon. The semi-colon is accepted by IBM's own db2 too, so it seems like a valid choice.
Any help in figuring out the cause of this error is much appreciated.
The problem was me forgetting to start my native sql file with this required line:
--liquibase formatted sql
Doh!

table does not exist error during execution on powercenter workflow

During execution of workflow, I am getting below error while inserting the data in the table (TARGET), whereas when I am connecting same database user then I am able to insert the data, but powercenter is throwing the below error.
I have already created the synonym as well as given all the access.
Severity Timestamp Node Thread Message Code Message
ERROR 23/05/2015 20:55:59 node01_CSADevelopment WRITER_1_*_1 WRT_8229 Database errors occurred:
ORA-00604: error occurred at recursive SQL level 1
ORA-00942: table or view does not exist
Database driver error...
Function Name : Prepare DPL
SQL Stmt : INSERT INTO TARGET(ID,NAME) VALUES ( ?, ?)
Oracle Fatal Error
Database driver error...
Function Name : Execute Multiple
SQL Stmt : INSERT INTO TARGET(ID,NAME) VALUES ( ?, ?)
Oracle Fatal Error
Please assist.
someone is running or finished running a DDL statement on the table and have not committed. Identify that oracle session and kill it or you can commit that transaction or wait until the timeout expires on that table.

JDBC Error in insert with DB2 (works with Sql Server)

I use in a Java Application JDBC to query the DBMS. The application works correctly with Sql Server but I get this error in DB2 during one insert:
com.ibm.db2.jcc.am.SqlDataException: DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=1, DRIVER=3.63.75
The insert is made using the ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE.
My query is a plain select of the table, then I declare my PreparedStatement, passing the parameters and afterwards with the ResultSet I do first the moveToInsertRow() and then the insertRow().
Do you know if there are any problems with this approach using DB2?
As I told you before the same code works correctly with Sql Server.
SQL Code -302 on DB2 means:
THE VALUE OF INPUT VARIABLE OR PARAMETER NUMBER position-number IS INVALID OR TOO LARGE FOR THE TARGET COLUMN OR THE TARGET VALUE
So it seems like you are trying to insert a value into a column which is too large or too short (e.g. Hello World into a varchar(5)). Probably the column has a different length in DB2 and sql-server or you are inserting different values.
Probably too late to add to this thread.. but someone else might find it useful
Got the same SQL Exception when trying to do a SELECT : didn't realize the property value in WHERE clause was exceeding the limit on the corresponding column
SELECT * FROM <schema>.<table_name> WHERE PropertyName = 'value';
value was a VARCHAR type but exceeded the Length limit
Detailed exception does say it clearly that data integrity was violated: org.springframework.dao.DataIntegrityViolationException
So a good idea would be to do a length check on the value(s) that are being set on the properties before firing any queries to the database.

Resources