void insert()
{
try
{
String sql="Insert into e_user (user_id, user_name, membership_no, email,
user_degree, password) values(user_userid_seq.NEXTVAL,?,?,?,?,?)";
Connection connection =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "imes", "imes");
PreparedStatement pst = connection.prepareStatement(sql);
pst.setString(1, txtname.getText());
pst.setString(2, txtmembership.getText());
pst.setString(3, txtemail.getText());
pst.setString(4, cbdegree.getSelectedItem().toString());
pst.setString(5, txtpass.getText());
pst.execute();
JOptionPane.showMessageDialog(null, "saved");
new Cases().setVisible(true);
Statement select = connection.createStatement();
ResultSet result = select.executeQuery("select user_id from e_user where email= ? ");
while(result.next())
{
int id = result.getInt("user_id");
JOptionPane.showMessageDialog(null, "Your id is" + id);
}
select.close();
result.close();
connection.close();
}
catch(SQLException | HeadlessException e)
{
JOptionPane.showMessageDialog(null, e);
}
}
This post has been edited by macosxnerd101: 03 July 2012 - 03:25 PM
Reason for edit:: Please use a descriptive title

New Topic/Question
Reply



MultiQuote







|