Error with createPreparedStatement [message #172367] |
Tue, 16 May 2006 03:58 |
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 #173004 is a reply to message #172999] |
Thu, 18 May 2006 22:09 |
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 |
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 |
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?
|
|
|
|
|
|