This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Change and delete rows in a sql-database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Change and delete rows in a sql-database" Watch "Change and delete rows in a sql-database" New topic

Change and delete rows in a sql-database

Marcus Borg

Joined: May 28, 2009
Posts: 1
Note, some of the code could be hard to understand as a bit is in Swedish.


I am trying to learn some sql/java. I created some tables in an sql-database, and a java-program to access and modify the tables. I am not that experienced in programming so I might have made some mistakes and I don't always know all the terminology. Anyway, here goes.

I made a GUI where you can switch from different tables using a scrollpane. I also have buttons and textfields for navigation and user input. I manged to find out how to change from different tables and how to add rows of data. I also ahve classes to run the program and classes to access to the database, and some methods in them,

This is how i show the table called Movies:

This is how I add rows to tables:

It seems a bit more complicated to delete rows and to change data in them. Mainly I am not sure how I should make the program understand which row that I want to change or delete. If it is possible to select a row in the scrollpane or somehow search in an array after the movie or staff that I want to change, I make the input using Textforms.

Any help would be great.


Complete code:

Rob Spoor

Joined: Oct 27, 2005
Posts: 20131

Since this is more SQL related than Swing related, I'm moving this to JDBC.

How To Ask Questions How To Answer Questions
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 44515
Welcome to JavaRanch

What happens when you try to delete a row from the command line? What SQL instructions do you use?
I agree. Here's the link:
subject: Change and delete rows in a sql-database
It's not a secret anymore!