• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

No operations allowed after statement closed.

 
Ranch Hand
Posts: 172
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all this is my code

Globally declared variables are




and I'm getting

No operations allowed after statement closed.

Where am I going wrong. Please Help

Thanks!
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your code, you did:



Where did you assign the variable statement?

You ought to use prepared statements, since you declared them

Just some suggestion:
your connection assignment can be outside the if statements because all connections are the same.
for sql, the where clause is specific to the if condition, the stuff before that is already know before hand as if all records are selected (or no where clause)
The rs.xxx and JTable's setXXX can be outside the if statement since all conditions will do it

 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where's that exception being thrown?

You might need to change your exception logging to:


And note you don't want to get in the habit of catching all Exceptions, you should catch specific ones.
 
Saloon Keeper
Posts: 28126
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Listen to Dave.

If I were to inherit the task of supporting your code and it was eating exceptions without either handling them or reporting them, you'd better hope that you can run really, really fast.
 
Pay attention! Tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic