Jtable how to use rs2xml

I am currently new to java, and I was looking for an efficient way to put database information in jtable, and I heard about rs2xml. I really want to find out, because other methods make me confused and give me a headache.

Does anyone know how to use it effectively? And if you don't mind, can you explain with simple code.

Thanks in advance.

+4
source share
2 answers
    import net.proteanit.sql.DbUtils;


  try {
    st = conn.createStatement();
    st.executeQuery(q);
    ResultSet rs = st.executeQuery(q);
    jTable1.setModel(DbUtils.resultSetToTableModel(rs));
       }
  catch (SQLException ex) {
  JOptionPane.showMessageDialog(null, ex);
   } finally {
     try {
    rs.close();
  } catch (SQLException e) { /* ignore */
  }

  try {
    st.close();
  } catch (SQLException e) { /* ignore */
 }
  }

what a sample use video tutorial

+3
source
  • // Before that, add rs2XML.jar to your project properties by adding // addLibray // option
private void b2ActionPerformed(java.awt.event.ActionEvent evt) {    

           int id = 0;
           String name = "";
           String mobile = "";
           String email = ""; 
           String flat = "";
           String query="";


           Connection con;
               try{
                 String query= "select * from apt"
                 con=DBconnect.ConnectDB();//it a class the connection properties are defined here
                 PreparedStatement ps; 
                 ps = con.prepareStatement(query);
                 ResultSet rs = ps.executeQuery();
                 jTable1.setModel(DbUtils.resultSetToTableModel(rs));


                    }

           }catch(Exception ee){
               ee.printStackTrace();
           }

       }
0

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


All Articles