private void PhoneDisplayActionPerformed(java.awt.event.ActionEvent evt) {
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc
dbc
cm"); //pcm is the dsn
PreparedStatement st = con.prepareStatement("select firstname,lastname,email1,city,state,country,mobile1,home from ContactsInfo"
+ "where firstname=?%");
st.setString(1,jComboBox7.getSelectedItem().toString());
JOptionPane.showMessageDialog(PhoneDisplay,"Retrieving Results....");
ResultSet rs = st.executeQuery();
int c = rs.getMetaData().getColumnCount();
rs.last();
int r = rs.getRow();
Object[][] data = new Object[r][c];
rs.first();
for(int i=0;i<r;i++)
{
data
[0] = rs.getInt(1);
data[1] = rs.getString(2);
data[2] = rs.getString(3);
data[3] = rs.getString(4);
data[4] = rs.getString(5);
data[5] = rs.getString(6);
data[6] = rs.getString(7);
data[7] = rs.getString(8);
rs.next();
}
Object[] col = {"First Name","Last Name","Email1","City","State","Country","Mobile","Home No."};
JTable t = new JTable(data,col);
QuerryFrame qf = new QuerryFrame();
qf.add(t);
qf.setSize(500, 600);
qf.setVisible(true);
con.setAutoCommit(true);
con.close();
}
catch (ClassNotFoundException ex) {
//Logger.getLogger(SearchPhone.class.getName()).log(Level.SEVERE, null, ex);
}
catch(SQLException se)
{
//JOptionPane.showMessageDialog(PhoneDisplay,"SQL Exception");
}