Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What about displaying fisrt some data in a JTable and, after, work with your database?</p> <p>1°) Extend an <a href="http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/table/AbstractTableModel.html" rel="nofollow">AbstractTableModel</a> that will represente your DB Table. This is a good and short <a href="http://www.java2s.com/Code/Java/Swing-JFC/TablewithacustomTableModel.htm" rel="nofollow">example</a>.</p> <p>2°) Then, with the appropriate JDBC driver, you'll be able to execute your <a href="http://www.java2s.com/Code/Java/Database-SQL-JDBC/JDBCselect.htm" rel="nofollow">Select queries</a> on your database and retrieve data.</p> <p>3°) By firing right events through your AbstractTableModel (see <a href="http://download.oracle.com/javase/1,5,0/docs/api/javax/swing/table/AbstractTableModel.html#fireTableDataChanged%28%29" rel="nofollow">fireTableDataChanged()</a>), your screen will be updated automaticaly</p> <p>4°) About delete record(s): you need to work with the <a href="http://download.oracle.com/javase/6/docs/api/javax/swing/JTable.html#selectionModel" rel="nofollow">selected</a> row(s). With it, you're able to reach your data (find primary key) and execute JDBC delete query. If and only if, your query is successfully executed, then update your internal data and fire events: <a href="http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/table/AbstractTableModel.html#fireTableRowsDeleted%28int,%20int%29" rel="nofollow">fireTableRowsDeleted(int, int)</a>, <a href="http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/table/AbstractTableModel.html#fireTableRowsInserted%28int,%20int%29" rel="nofollow">fireTableRowsInserted(int, int)</a>, etc.</p> <p>Good luck!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload