Home > Back-end >  I am a beginner, this code can change to the query to the database information with table display? P
I am a beginner, this code can change to the query to the database information with table display? P

Time:09-20

Package first1;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
The import manager. LianJie;
Public class NNN extends JFrame {
JButton button;
//data table;
JPanel panel;
int amount;
Int the column;
//String oo1 [] [];
//String o1 [];//={" ni ", "ni", "ni", "ni"};
AL AL=new AL ();
Public void nnn1 () {data table; String oo2 [] []; O2 String []; The button=new JButton (" button ");//oo=new String [amount] [columnnumber]; Oo2=al. Oo1; O2=al. O1; Table=new series (oo2, o2); The panel=new JPanel (); The panel. SetLayout (new BorderLayout ()); A panel. The add (button, BorderLayout. NORTH); A panel. The add (new JScrollPane (table), BorderLayout. CENTER); Add (panel); Button. AddActionListener (al);
}
The class AL implements ActionListener {String oo1 [] []; String o1 [];
Public void actionPerformed (an ActionEvent e) {Connection con=null; Con=LianJie. LianJie (); If (con==null) return; The Statement st. The ResultSet re; Int columnnumber; Try {st=con. CreateStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_READ_ONLY); Re=st. executeQuery (" select * from the UserInfo "); Re. The last (); The ResultSetMetaData RSMD=re. For getMetaData (); Columnnumber=RSMD. GetColumnCount (); O1=new String (columnnumber); for(int i=0; i}} public static void main (String args []) {NNN n=new NNN (); N.s etTitle (" big "); N.s etSize (500500); N.s etLocationRelativeTo (null); N.s etDefaultCloseOperation (JFrame. EXIT_ON_CLOSE); N.s etVisible (true); N.n nn1 (); }

}

CodePudding user response:

Would you like to see such a format code

CodePudding user response:

The first post, copied to show like this, the original is not the case,
  • Related