Hi
i m new in java trying to do a small form for creating rows..
i have a next button to scroll all my database
everytimes i run it i have the first record then it says null
please find my code for this issue
private void AfficherStagiaire(){
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost/cabinet","root","root");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Statement sqlState = null;
try {
sqlState = conn.createStatement();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String selectStuff = "Select * from customer";
// ResultSet rows = null;
try {
rows = sqlState.executeQuery(selectStuff);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
if(rows.next()){
nombre=rows.getInt("custnum");
trading=rows.getString("tradingname");
over=rows.getString("overshop");
cab=rows.getString("cabinet");
addr=rows.getString("address");
c1=rows.getString("contact1");
c2=rows.getString("contact2");
ph=rows.getString("phone");
m=rows.getString("model");
as=rows.getString("asset");
cre=rows.getString("cr");
mr=rows.getString("modelr");
asr=rows.getString("assetr");
mot=rows.getString("motif");
// num.setToolTipText(nombre).tostring();
num.setText(String.valueOf(nombre));//seatsTF.setText(String.valueOf(e.Age()));
name.setText(trading);
shop.setText(over);
address.setText(addr);
person1.setText(c1);
person2.setText(c2);
person3.setText(ph);
//cabine.setText(cab);
model.setText(m);
asset.setText(as);
// ((JComboBox) cr).setToolTipText(cre);
modelr.setText(mr);
assetr.setText(asr);
motif_1.setText(mot);
}
else {
rows.previous();
JOptionPane.showMessageDialog(null, "end of file" );
}
} catch(Exception ex)
{
JOptionPane.showMessageDialog(null, "Error\n"+ex.getMessage() );
}
}