-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexcute
57 lines (52 loc) · 1.37 KB
/
excute
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package Pacakage;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.Normalizer.Form;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import java.awt.Toolkit;
import java.sql.PreparedStatement;
public class DB_test2 extends JFrame{
static PreparedStatement pstmt ;
static ResultSet rs;
static DB_con DB;
public DB_test2() throws SQLException {
new DB_Form();
qry();
}
void qry() throws SQLException {
int i=0;
DB.open();
String sql = "SELECT * FROM customer";
try {
pstmt = DB.conn.prepareStatement(sql);
rs = pstmt.executeQuery();
rs.next();
DB_Form.table.setAutoCreateRowSorter(true);
do {
/*
* table.setValueAt(rs.getString("ID"), i,0);
* table.setValueAt(rs.getString("cName"), i,1);
* table.setValueAt(rs.getString("Age"), i,2);
* table.setValueAt(rs.getString("job"), i,3);
*/
i++;
String cName = rs.getString("cName");
String Age = rs.getString("Age");
String job = rs.getString("job");
Object[] rowData = {cName, Age, job};
DB_Form.dtm.addRow(rowData);
}while(rs.next());
}catch(SQLException e) {
e.printStackTrace();
System.out.println("실패");
}
DB.close();
}
public static void main(String[] args) throws SQLException {
new DB_test2();
}
}