This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

No operations allowed after statement closed.

 
Ranch Hand
Posts: 172
Netbeans IDE MySQL Database Java
  • 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!
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser 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

 
Rancher
Posts: 4625
47
  • 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.
 
Saloon Keeper
Posts: 22289
151
Android Eclipse IDE Tomcat Server Redhat Java 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic