Add a row to JTable and Database (phpMyAdmin)?

前端 未结 1 604
醉话见心
醉话见心 2021-01-27 20:43
initComponents(); 
try {
        ResultSet res = statement.executeQuery(\"SELECT * FROM banh\");
        ResultSetMetaData RSMD = res.getMetaData();
        NumberOfColu         


        
相关标签:
1条回答
  • 2021-01-27 20:52

    That is a poor example to use:

    1. Variable names should NOT start with an upper case character.
    2. Hardcoding the array size to support 10,000 rows is the wrong approach. You can also use Vector which are dynamic.

    Instead check out the Table From Database Example code found in Table From Database. This example uses Vectors which will grow depending on the number of rows found in the ResultSet.

    I don't know how to add row to JTable and Database

    1. You can use the addRow(...) method of the DefaultTableModel to add data dynamically. Read the API or search the forum/web for examples that use the addRow(...) method.

    2. For database inserts you can start with the tutorial on JDBC Database Access.

    0 讨论(0)
提交回复
热议问题