+ Start a Discussion
Sridhar VenkateswaraluSridhar Venkateswaralu 

Invalid Query Locator Exception Using DataBase.QueryLocator

Hi All,


I am hitting Invalid Query Locator Exception,  and i am not able to catch this exception also. I am using the Database.QueryLocator for retreiving the records and displaying them on to the visual force page. I am not able to debug this issue also as this exception is not consistent. any suggestions would be of great help.


waiting for your reply,




Ritesh AswaneyRitesh Aswaney

You will encounter an Invalid Query Locator error, generally when the SOQL Query itself is malformed.


Its prolly a good idea to print out the query string that you're constructing and try executing that in the SOQL Explorer or in the IDE.


If you are QueryLocator for achiving pagination and you are doing next/previous after keeping page idle for 15 mins.

basically then it throws the error which can't be handled in catch block.


if this is issue then ping me , i have the solution for this.

Sridhar VenkateswaraluSridhar Venkateswaralu

If that is the case then i should be hitting this exception all the time right??? I m getting this exception very rarely, but am  not able to catch it.


You will be geting this exception clicking next/prev after keeping page idle for 15 mins.

The issue with query locator is , its expire after 15 min bcause its server side cursor to the that perticular db table.


So solution for this, you should be using Query locator action within evry 15 mins to keep it alive.

So what u can do is put ActionPoller into ur panel in which u have that pbt or any list component and have interval for 14 mins and call action="makeAlive()" for actionPoller


public void makeAlive





Issue Resolved. B happy