• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ajax autocomplete

 
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am using a ajax autocomplete component from http://www.dhtmlgoodies.com/index.html?whichScript=ajax-dynamic-list.

My problem is that i get a SQL error if the ajax component calls the servlet faster than it can handle. The error is:
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after statement closed.

Let�s say the number of letters to be entered is 3 before a servlet lookup is performed. If the user enters 3 letters ('pet') it works fine. But if the user enters 4 letters (too fast) the ajax component calls the servlet twice ('pet') and ('pete'), and an error occurs.

I can avoid the the above error by doing the servlet synchronized, but is that a good solution? Any other ways to solve the problem?

public synchronized void service ( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
}

Thanks in advance.

[ January 02, 2009: Message edited by: Jeppe Sommer ]
[ January 02, 2009: Message edited by: Jeppe Sommer ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually it sounds as if your server components are poorly written. There should be no issues with conflicts between the separate queries. I'd check your server code to make sure you are following correct practices.
[ January 02, 2009: Message edited by: Bear Bibeault ]
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my servlet code:

 
reply
    Bookmark Topic Watch Topic
  • New Topic