How to bind database table to JTable and use JTable to modify and add rows

In fact, I use netbeans to develop a quick interface for adding and modifying data to and from the database. The program is simple, it consists of a JTable bound to a table in my database. I want something that requires the least amount of code.

I want to be able to modify and add lines. this article shows how to bind data to my JTable: http://blogs.oracle.com/NetBeansSupport/entry/populating_jtable_from_mysql_database

The first problem is that when editing a cell, it does not change in the database. The second problem is that I want to be able to add a link to the table. Then the last problem is that there are relationships between some of my tables, and I want to have a combobox look in the rows of the foreign key in order to associate the row of the current table with another row of another table. The problem is that I don’t have much time for this, so if there is a way to do this automatically, I appreciate it.

+3
source share
2 answers

There is no way to do this automatically, which I know of.

, VB .NET, Java.

, Listeners, Swing JDBC.

Google , NetBeans , , IDE.

, , .

0

-, Node, usertblList [list] , , :

    String email = txfEmail.getText();
    String name = txfName.getText();
    String surname = txfSName.getText();

    Usertbl obj = new Usertbl();
    int idNO = 1;
    for (Usertbl usertbl : usertblList) {
        idNO++;
    }

    obj.setId(idNO);
    obj.setEmail(email);
    obj.setName(name);
    obj.setSurname(surname);


    DatabaseNamePUEntityManager.getTransaction().begin();
    DatabaseNamePUEntityManager.persist(obj);
    DatabaseNamePUEntityManager.getTransaction().commit();

0

Source: https://habr.com/ru/post/1787307/


All Articles