• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No operations allowed after statement closed.

 
Pranit Sonawane
Ranch Hand
Posts: 172
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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!
 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • 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

 
Dave Tolls
Ranch Hand
Posts: 2095
15
  • Mark post as helpful
  • send pies
  • 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.
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic