我在mysql中有一个数据库和表,我想从我的一个表中检索特定行并将其存储到String变量中。 我尝试了如下但未成功
connect c = new connect(); 连接con = c.start();
PreparedStatement ps = con.prepareStatement("select semester from tfee where semester ='I' ");// I want this **semester asigned to String s1 ;**
ps.setInt(1, semester.getSelectedIndex());
ResultSet rs = ps.executeQuery();
int x =0;
if(rs.next())
x=1;
if (x==1)
{
JOptionPane.showMessageDialog(this,"Login Success");
mainForm m = new mainForm();
m.setVisible(true);
dispose();
}
else
{
JOptionPane.showMessageDialog(this,"Login Fail, Incorrect User ID and/ Password");
}
c.stop();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this, e);
}