I have written a query that has NEXT VALUE FOR AVS_Interface_ControlID as controlID which is a valid sequence. I get the error:
Caused by: java.sql.SQLException: Invalid object name 'AVS_Interface_ControlID'.
When I run this exact query in MSSQL Server Management Studio, I do not get an error and the sequence is displayed correctly and increments. I've tried using dbo. and DBName.dbo. and those don't help. I am logging into the DB as SA for both attempts.
Is "Next value for" not allowed with Java prepared statement calls? or am I missing something?
Related
My code is simple
CallableStatement stmt = Conn.prepareCall ("{call Reconciliation (?)}");
stmt.setString(date);
PS.executeUpdate();
Am using Sybase (Adaptive Server Enterprise/15.7.0) and jconnect4 drivers if it is relevant to solution.
My procedure(Reconcliliation) is quite huge so I couldn't post it here but it does some updates to some 1 tables (Recon) after some comparison of data from another 2 tables (Deals1 and Deals2). It do not return any out parameters in procedure, it takes only 1 in parameter which is date.
When I run java code and run the procedure using callable statement it produces some updates data in table (Recon, count is 500) and the error I get after that is this :
java.sql.SQLException: JZ0P1: Unexpected result type.
at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.executeUpdate(Unknown Source)
at com.sybase.jdbc3.jdbc.SybCallableStatement.executeUpdate(Unknown
Source)
at DBConnection.ExecuteProc(DBConnection.java:88)
Am pretty sure there is no error in my procedure (Reconciliation) because when I run the same procedure in Aqua Data Studio with command exec Reconciliation '04-Dec-2016' it doesn't give any error and produces full update in tables (Recon, total count is 800).
There is no error in java as well because it is giving sql exception. If am not wrong there must be some problem in middle i.e jconnect drivers or something else.
Please help me with this, thanks in adv.
Old question, but I couldn't find any good answers to this question online when I had the same problem.
The big hint came from http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc39001.0700/html/prjdbc0700/CHDGJJIG.htm
JZ0P1 Unexpected result type.
Description: The database has returned a result that the statement cannot
return to the application, or that the application is not expecting at this
point. This generally indicates that the application is using JDBC incorrectly
to execute the query or stored procedure. If the JDBC application is connected
to an Open Server application, it may indicate an error in the Open Server
application that causes the Open Server to send unexpected sequences of results.
The stored procedure is returning tables. Don't do:
PS.executeUpdate();
But do this instead:
ResultSet rs = callableStatement.executeQuery();
For old jdbc drivers, I´ve noticed that
PS.executeUpdate();
raises this error while
PS.execute();
does not
I am having some trouble with my java app querying an Access DB (.mdb). I am getting this error:
[Microsoft][ODBC Driver Manager] Invalid string or buffer length
but only when attempting to call resultset.getString("xxx") on certain rows. About half of the rows that I am querying process just fine but the other half give me this error. It seems like a problem with the data in the row itself but I can't quite figure out what would cause this.
I have a MySQL Stored Procedure click here for stored procedure and calling the Procedure using Hibernate
Hibernate Code:
int ps=5;
SQLQuery query=session2.createSQLQuery("CALL AbsentReportproc(:_fromdate,:_todate)");
query.setParameter("_fromdate", fromdate);
query.setParameter("_todate", todate);
query.setFirstResult(ps*(pno-1));
query.setMaxResults(ps);
List<Object[]> empList=query.list();
when I execute above code I'm displayed with the following Error Message:
org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 5' at line 1
Note:If i remove the below statement from the code,I'm displayed with all records in a single jsp Page
query.setMaxResults(ps);
Could any one give me the solution what was the Problem?
thanks...
It is clearly a jdbc driver error that you are using;
Also try this with setFetchSize , and if this doesn't work also then,
I would suggest not to get the details out of the query in chunks if you want to display them all and there is not much data and you should rather store all the data without calling this method query.setMaxResults(ps); into a collection.
And when you want to display that data in pages, then get subList in case you are using List, to break the data at the application level and then display it on your view that is jsp in this case.
Here i have probably a simple question.Im trying to connect to DB2 databvase and execute SPs through java.Im able to connect to the database but while executing the SP got the error.Please let me know how to solve this.By the way, im putting all the JDBC url,schema,usrname and password in a properties file and running a batch file
Here is the Stack trace when i ran the Batch file
URL :`jdbc:db2://ip:50001/RMSDB:currentSchema=etwrms;currentPackagePath=etwrms,sysibm,sysfun,sysproc;currentFunctionPath=sysibm,sysfun;
Santosh....after WF_NON_MSG_SEND
ERROR [main] WorkflowMailer (processcycle:344) - DB2 SQL Error: SQLCODE=-440, SQ
LSTATE=42884, SQLERRMC=WF_NON_MSG_SEND;PROCEDURE, DRIVER=3.57.82
com.ibm.db2.jcc.am.io: DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884, SQLERRMC=WF_
NON_MSG_SEND;PROCEDURE, DRIVER=3.57.82
at com.ibm.db2.jcc.am.bd.a(bd.java:676)
at com.ibm.db2.jcc.am.bd.a(bd.java:60)
at com.ibm.db2.jcc.am.bd.a(bd.java:127)
at com.ibm.db2.jcc.am.km.c(km.java:2506)
at com.ibm.db2.jcc.am.km.d(km.java:2483)
at com.ibm.db2.jcc.am.km.a(km.java:1963)
at com.ibm.db2.jcc.t4.db.g(db.java:139)
at com.ibm.db2.jcc.t4.db.d(db.java:75)
at com.ibm.db2.jcc.t4.t.d(t.java:63)
at com.ibm.db2.jcc.t4.sb.k(sb.java:170)
at com.ibm.db2.jcc.am.km.fb(km.java:1958)
at com.ibm.db2.jcc.am.lm.kc(lm.java:2813)
at com.ibm.db2.jcc.am.lm.b(lm.java:3515)
at com.ibm.db2.jcc.am.mm.Yb(mm.java:113)
at com.ibm.db2.jcc.am.mm.execute(mm.java:96)
at com.ramco.rvw.workflow.mail.WorkflowMailer.processcycle(WorkflowMaile
r.java:338)
at com.ramco.rvw.workflow.mail.WorkflowMailer.main(WorkflowMailer.java:6
5)
`
The next time you get a DB2 error, you can go to this handy error message website to find the reason.
-440
NO AUTHORIZED routine-type BY THE NAME routine-name HAVING COMPATIBLE ARGUMENTS WAS FOUND IN THE CURRENT PATH
Explanation
An attempt was made to invoke a routine, but DB2® could not resolve the invocation of a routine, including the argument list, to a specific routine definition.
routine-type
The type of routine, such as FUNCTION or PROCEDURE.
routine-name or schema-name.routine-name
The name of the routine. If the originating statement references a qualified name, the routine name in the message text is qualified by the name of the schema.
Possible causes for this error include:
The routine name was either incorrectly specified or does not exist in the database.
A qualified reference was used, and the schema qualifier was incorrectly specified.
The user's SQL path does not contain the schema to which the desired function belongs, and an unqualified reference was used.
The wrong number of arguments was included.
The right number of arguments was included in the routine reference, but the data type of one or more of the arguments is incorrect.
The invoker of the routine is not authorized to execute the routine.
Your Response
Take a look at your SQL statement and figure out what's wrong.
In my java program an update query is used like below,
update unsub_tbl set stat=1 where stat=0 and emp_id='4441' and action='1';
if unsub_tbl is empty, then trying to update using above update query gives exception:
java.sql.SQLException: Can't find record in 'unsub_tbl'
But it's not giving the exception all the time for same condition. Why does it only give the exception sometimes?
It seems that it is a bug with MySQL 4.0.14+
Refer MySQL Bugs