Home » Developer & Programmer » JDeveloper, Java & XML » Error with createPreparedStatement
Error with createPreparedStatement [message #172367] Tue, 16 May 2006 03:58 Go to next message
cuongtv
Messages: 34
Registered: August 2005
Location: Vi�t Nam
Member

I have error with createPreparedStatement
public void executeASReport(String vstrSQL)
{
PreparedStatement stmt= null;
String strSQL = "";
try
{
DBTransaction dbTrans = this.getDBTransaction();
strSQL = strSQL + vstrSQL;
stmt = dbTrans.createPreparedStatement(strSQL, DBTransaction.DEFAULT);//Error here: java.sql.SQLException: Invalid argument(s) in call: setFetchSize
stmt.executeQuery();
stmt.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
Re: Error with createPreparedStatement [message #172467 is a reply to message #172367] Tue, 16 May 2006 12:32 Go to previous messageGo to next message
hobbes
Messages: 173
Registered: January 2006
Senior Member
What happens if you use a positive integer, say 1, instead of DBTransaction.DEFAULT? Please check if the value of DBTransaction.DEFAULT is valid.
Re: Error with createPreparedStatement [message #172999 is a reply to message #172367] Thu, 18 May 2006 20:58 Go to previous messageGo to next message
cuongtv
Messages: 34
Registered: August 2005
Location: Vi�t Nam
Member

I've replaced with a positive, but I still have error:
java.sql.SQLException: Invalid argument(s) in call: setFetchSize
in createPreparedStatement
Re: Error with createPreparedStatement [message #173004 is a reply to message #172999] Thu, 18 May 2006 22:09 Go to previous messageGo to next message
hobbes
Messages: 173
Registered: January 2006
Senior Member
Is it possible for you to run your code in "Debug" mode where you 'step into' the execution of createPreparedStatement? That would help locate the exact cause of the problem.

I assume that the code does not explicitly call setFetchSize elsewhere?
Re: Error with createPreparedStatement [message #173011 is a reply to message #172367] Thu, 18 May 2006 23:28 Go to previous messageGo to next message
cuongtv
Messages: 34
Registered: August 2005
Location: Vi�t Nam
Member

Ok, I've done that. When I debuged, I found that:
Name Value Type
- DBTransaction.DEFAULT -1 int
- dbTrans DBTransactionImpl2
- stmt null PreparedStatement
- strSQL " SELECT empname, titlename, shortname, firstadvance FROM v_AdvanceSalaryReport WHERE Period= 'DEC-20" String
value " SELECT empname, titlename, shortname, firstadvance FROM v_AdvanceSalaryReport WHERE Period= 'DEC-20" char[222]
offset 0 int
count 127 int
hash 0 int

But my vstrSQL I put in is:
" SELECT empname, titlename, shortname, firstadvance FROM v_AdvanceSalaryReport WHERE Period= 'DEC-2005' And Departmentid = '1' "

[Updated on: Thu, 18 May 2006 23:29]

Report message to a moderator

Re: Error with createPreparedStatement [message #173050 is a reply to message #173011] Fri, 19 May 2006 03:34 Go to previous messageGo to next message
hobbes
Messages: 173
Registered: January 2006
Senior Member
You are appending strSQL and vstrSQL together, but from the debug information both look like separate queries.

Can you check if the final SQL i.e. after
strSQL = strSQL + vstrSQL;
is valid? Execute it separately and see if it gives any errors.

Also, DBTransaction.DEFAULT is -1, change this to 1?


Re: Error with createPreparedStatement [message #173054 is a reply to message #172367] Fri, 19 May 2006 03:49 Go to previous messageGo to next message
cuongtv
Messages: 34
Registered: August 2005
Location: Vi�t Nam
Member

I've checked it, I assigned: strSQL = vstrSQL. I used: Debug.println(strSQL), it was corrected. But it still raise error
Re: Error with createPreparedStatement [message #173095 is a reply to message #173054] Fri, 19 May 2006 06:47 Go to previous messageGo to next message
hobbes
Messages: 173
Registered: January 2006
Senior Member
How about the value of DBTransaction.DEFAULT - could you set it to 1 instead of -1?
Re: Error with createPreparedStatement [message #173171 is a reply to message #172367] Fri, 19 May 2006 21:02 Go to previous message
cuongtv
Messages: 34
Registered: August 2005
Location: Vi�t Nam
Member

Of course, I've replaced DBTransaction.DEFAULT (value = -1) with 0 or 1 or 2, but it still error.
Previous Topic: Cannot convert between UTF8 and UCS2
Next Topic: Database connection error. Error: Protocol violation
Goto Forum:
  


Current Time: Fri Apr 26 17:10:40 CDT 2024