hay
i am new in java world, please guide me , i have made a phone directory and i have also maintained a database for this. i want on clicking the next button each row from database table display one by one on the GUI into their relevant text Fields. i have written this code , this code show the last row of the table on single click on next button. i want one by one row on each next button click. please if u provide me little bit solution
private void next_contactActionPerformed(java.awt.event.ActionE vent evt) {
try{
String Url = "Jdbc:OdbcirDSN";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(Url,"sa","mysql");
String sql = "SELECT * FROM PersonInformation";
PreparedStatement pstmt = con.prepareStatement(sql,
ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR _UPDATABLE);
ResultSet rs = pstmt.executeQuery();
while(rs.next())
{
String name = rs.getString("First_Name");
String lName = rs.getString("Last_Name");
String add = rs.getString ("Address");
String em = rs.getString("Email_Id");
String cell = rs.getString("cell#");
jTextField2.setText(name);
jTextField3.setText(lName);
jTextField4.setText(add);
jTextField5.setText(em);
jTextField10.setText(cell);
}
con.close();
}
catch(Exception sqlEx)
{
System.out.println(sqlEx);
}
finally{
}
}