473,769 Members | 4,470 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JTable and RowSet

Hi fellows,

I was wondering if in the Java API there's a way to easily map a
disconnected RowSet to a JTable... I have looked at the doc but i did
not found anything.

What I want is simply do the follow:

1. Load: Database -> disconected Rowset -> automapping in a JTable
2. Editing of the data in the table/rowset
3. Save (clicking on a button): commit the rowset to the database

Otherwise:
1. Load: Database -> disconected Rowset -> automapping in a JTable
2. Editing of the data in the table
3. Save(clicking on a button): remapping of the table in the roset
4. and then commit the rowset to the database

Any suggestion on how to do this in the simplest way is greatly
appreciated...

Thanks in advance,
Andrea
Jul 17 '05 #1
1 6742
Andrea Sansottera wrote:
Hi fellows,

I was wondering if in the Java API there's a way to easily map a
disconnected RowSet to a JTable... I have looked at the doc but i did
not found anything.

What I want is simply do the follow:

1. Load: Database -> disconected Rowset -> automapping in a JTable
2. Editing of the data in the table/rowset
3. Save (clicking on a button): commit the rowset to the database

Otherwise:
1. Load: Database -> disconected Rowset -> automapping in a JTable
2. Editing of the data in the table
3. Save(clicking on a button): remapping of the table in the roset
4. and then commit the rowset to the database

Any suggestion on how to do this in the simplest way is greatly
appreciated...

Thanks in advance,
Andrea

I wouldn't waste your time with the disconnected Rowset... You can
operate on the live one just as well... The caveat is that the table
you show can't be created as a result of an SQL join.

That being said, just implement a TableModel that delegates to the
Rowset (or ResultSet). The key is figuring out how many rows there are.
You can either move the SQL cursor to the end and find out the current
row or run another statement like "SELECT Count(*) From...)

Once you've got the row number for the TableModel, you don't have to
read all of the rows to satisfy the TableModel requirement. As for the
data access, just move the SQL Cursor to the appropriate column/row when
requested by the JTable.

Access is quite fast, and you don't even have to read the entire ResultSet.
As for updating, there's the ResultSet API that allows you to edit the
data in place.

-Bryan
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8634
by: Ben Munday | last post by:
Hi all, I have a problem with a Checkbox in a JTable. When i add the Checkbox into the JTable it displays the String representation of the Checkbox, which is not what i want. So, i created a CheckBoxRenderer which extens Checkbox and implements TableCellRenderer. This seems to have done the job, in that the Checkbox is displayed and not the String representation. But, and it's a big 'but', the column that holds the Checkbox continually...
1
8973
by: asd | last post by:
I need to make the cells in the 1st column look like the column header. I tried the following code but it didn't change anything: private void rendererTest() { TableColumn column = tblDecisions.getColumnModel().getColumn(0); TableCellRenderer renderer = column.getHeaderRenderer(); column.setCellRenderer(renderer); }
1
7974
by: raysaun | last post by:
I am trying to set a TableCellEditor for a JTable, however, the editor never seems to get called. I can not even get a simplified version (below) to work. When I put a breakpoint on the return statement in getTableCellEditorComponent, it never stops there even though I edit cells in the table. Can anyone tell me what I am missing. By the way, I have gotten TableCellRenderers to work with no problems. public class Frame1 extends...
0
3146
by: sivaprasad06 | last post by:
Hi, I have a editable combo box editor as a cell editor for JTable. I want use only key board to enter data into jtable. so i am using ALT+Down comobination for making cell editiable in the jtable. when user clicks that combination what ever editor present in that cell will appear. I am using tab for traversing all cells in table.
0
3396
by: nuria | last post by:
hi, I have an editable JTable, when you are editing it and press F8 shows a dialog and then go again to the JTable window but the focus goes to a JtextField component, go with the tab for the rest of the textfields and when have to get the focus again the JTable can´t get it !!! only if I go with the mouse!!!! I am trying all things, give the focus to other component before call the Jdialog, put visible(false) the JTable before call...
1
7388
by: onsir | last post by:
I have code like this, but still wrong. how to show data from database in JTable. package my.JavaNetBean; import java.sql.*; import java.io.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException;
7
17217
blazedaces
by: blazedaces | last post by:
Hi guys, what I'm I have is a jtable with boolean variables in the first column and text in the next two (checkboxes). I want my tableChanged method to make it so when I check one of the checkboxes then it would change whether that third column is editable or not. I have made a short array that would hold values of either 0 or 1, basically whether or not each cell is editable or not. Along with that is obviously a setEditable(int row, int...
5
9850
by: moizpalitanawala | last post by:
Hello friends, How to add data to JTable from a .txt file. I had seen this code from one of the tutorial from java.com. This code doesnt take any input. But shows what is written in the array. But i want the table to display the data from a .txt file in which i had stored information in this format. Can anyone please modify the codes and explain me. Name:Mr.xyz Phone:111111222222
1
5842
by: emekadavid | last post by:
can anyone help me flesh out the problem? I wanted to insert a combo box into one of the columns of a JTable. although the combo box is drawn, the list of the data model fails to render. import java.awt.*; import javax.swing.*; import javax.swing.table.*; public class TableAvecRenderer extends JPanel {
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10225
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3969
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.