This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Delete Records form Database

 
Sander Silva
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I need to Delete Records form MS Access Database.

I have 2 files.

1 to get value from Gui and 2nd contains SQL code.

I think problem is mainly in my SQL statement rather than in Java code.

What I want to do is, get the integer value (SVID) from GUI and
Delete all records match the SVID in the Main table of my database.

DeleteCode.java


DeleteGui.java


Please kindly help.

 
Fatih Keles
Ranch Hand
Posts: 182
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use PreparedStatement and it's setX methods.

 
Sander Silva
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much

It's working 100%, I can delete the ID i need

but, I'm getting this error

Error: java.lang.NullPointerException
 
Fatih Keles
Ranch Hand
Posts: 182
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can be anything, can you provide a stack trace and more code?
 
Sander Silva
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you again for kind help,

Here's more code



and



 
Fatih Keles
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Statement s is never initialized but you try to close it in your closeDb() method which is generating the NullPointerException since s is null.

After exception your database connection is not closed!!!. You should use finally blocks so that you don't leave any connection open and Exceptions are easy to be determined if you use printStackTrace method of Exception object.
 
Sander Silva
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic