Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6993223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:44:14+00:00 2026-05-27T19:44:14+00:00

I want to bind a database table to a swing JTable, and make that

  • 0

I want to bind a database table to a swing JTable, and make that JTable editable by using APIs in a updatable ResultSet(#insertRow,#deleteRow(),#updateRow()).

so I need to create a TableModel implementation by wrapping a ResultSet.

public class MyTableModel implements TableModel {

private ResultSet rs;

private ResultSetMetaData rsmd;

@Override
public int getRowCount() {
    return 0;
}

@Override
public int getColumnCount() {
    return 0;
}

@Override
public String getColumnName(int columnIndex) {
    return null;
}

@Override
public Class<?> getColumnClass(int columnIndex) {
    return null;
}

@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
    return false;
}

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    return null;
}

@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {

}

@Override
public void addTableModelListener(TableModelListener l) {

}

@Override
public void removeTableModelListener(TableModelListener l) {

}

}

then, how Can I implement the getRowCount() method ?

how to determine the numbers of rows in a updatable result set ?

for example, if user click a button “add row”, then I call such methods :

        rs.moveToInsertRow();
        rs.updateString(1, "yqwang");
        rs.insertRow();

how to sync the JTable UI and the underlying ResultSet?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:44:15+00:00Added an answer on May 27, 2026 at 7:44 pm

    You should not do that. A ResultSet needs an open connection to the database, and the changes done to the result set won’t be committed to the database until you commit the connection.

    This means that if the database decides to close the connection because it hasn’t seen any activity for some time, or if your app crashes after three hours, you’ll lose all the modifications done during these 3 hours.

    This also means that you might lock some rows for a whole lot of time, and thus make other transactions wait for a whole lot of time before being able to do anything.

    Copy the data from the result set into your table model, and start a new transaction each time you need to insert or update a row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Elixir in a project that connects to a postgres database. I want
I want to retrieve data from 2 columns of my database table and bind
Using jQuery I want to bind an existing function to a button. I've been
I have a datasource that I want to bind to a listview that has
How do I bind data or info from a database table to the labels
i'm using MS northwind database, and use Entity Framework. I want to create new
Here is what i have: a SQL CE database, that holds this Category table,
In my application I have a sqlite database that looks like this: CREATE TABLE
I want to bind a MySQL database to my WPF GridView. But this doesn't
In my sql server table, I want to add a computed column that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.