Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Win a free book! (or whatever)  RSS feed

 
Michael Hildner
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, for help leading to the success of my project, I'll give you a $50 gift certificate to Amazon.com, a $50 gift certificate to where ever you'd like (great gift idea!), or I'll just send you a check for 50 bucks.
I have been struggling for quite a while trying to do something that seems like it should be standard, generic stuff, but I find it difficult to find examples, or even discussion. It's a mix of Swing and JDBC.
What I've got is a bunch of tables in an Oracle database. My project is to develop a Swing interface that should be something along the lines of having a list of tables, when the user clicks on a table name, the table shows up and the user can add, delete and modify records. FYI I've been working with Java for about 3 months.
A good portion of this project is complete. Things work fine and the user can modify existing records. Now I'm down to the hard part. Having difficulty with adding a row. I'd really like the user to hit the down arrow when at the end of a table, which would create a new, blank row, which then should get committed when the user moves off that row. This exact implementation is not required, I'd be happy to add a record in any fashion. I also need to have delete functionality.
The JTable is created from a scrollable result set using a table model that extends AbstractTableModel.
If anyone can give some guidance, it would be greatly (and concretely) appreciated.
Michael
 
Ashutosh Uprety
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
if u r just looking for how to add a row, i will give u a piece of code that I wrote for fun.
The details are like this(for what I have written). Its all in swings and uses Type 4 driver (MySQL).
I have a frame on which i get a panel displayed. This panel has textfields for user inputs. eg. employee name,empid,company,etc.
U enter the values and press the commit button, the row gets added into the database. I have used MySQL server for my application. If u think it is useful to u, send me a mail at
ashutosh.uprety@wipro.com
i will send u the full code of what i have written. U can customise it for compatibility with oracle. Otherwise I can help u out in this regard if u give me the actual specifics eg. screen prints of ur frames, details regarding Oracle driver,the inputs required,etc. I hope it will help u.
Ashu.
 
Michael Hildner
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ashu,
Thanks for the reply. Is your input box that gets displayed dynamic? I'd hate to code dozens of input boxes.
Although not exactly what I wanted (which would be an empty row in the table), we ended up passing the table model to a dialog box that gets info from the table model to build a new, one-row table. After the user adds information, the information in the new model is inserted into the record set. So far it seems to work pretty well.
But hey, I'm not cheap I'd like to hang out for a while to see if anyone has a solution to this. If not, you win!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!