aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Ajax autocomplete Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax autocomplete" Watch "Ajax autocomplete" New topic
Author

Ajax autocomplete

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
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 ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Here is my servlet code:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax autocomplete
 
Similar Threads
Regular Expression
Gadgets library?
Auto-suggest/Auto-complete fields
Your favourite Cartoon Character of all time!
How to get aroun LazyInitialization exceptions using Spring HibernateDaoSupport?