日期:2014-05-20 浏览次数:20702 次
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
tableModel=new DefaultTableModel(entity.searchCustomer(getName() ), getTitles());
//System.out.println(entity.searchCustomer(getSearchCustomerName() ));
jTable1 = new javax.swing.JTable(tableModel);
jScrollPane1.setViewportView(jTable1);
}//GEN-LAST:event_jButton1MouseClicked
public Vector getTitles() {
titles.add("id");
titles.add("name");
titles.add("age");
return titles;
}
public String getName() {
return new String(jTextField1.getText());
}
public Vector searchCustomerInfo = new Vector();
public Vector searchCustomer(String name) {
String sql = "select * from users_xiey where name like'%" + name + "%'";
// System.out.println(sql);
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
// Vector rowData = new Vector();
try {
conn = ConnectionUtils.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {