Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table temp (
- id int IDENTITY(1,1) PRIMARY KEY,
- name varchar(32) not null,
- username varchar(32) not null,
- contact varchar(32) not null,
- gender int
- );
- btnSubmit.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- try
- {
- int gender = 0;
- Connection sqlCon = DB_con.getSQLConnection();
- PreparedStatement ps = sqlCon.prepareStatement(
- "insert into temp (name, username, contact, gender) values ( ?, ?, ?, ?)"
- );
- ps.setString(1, txtName.toString());
- ps.setString(2, txtUserName.toString());
- ps.setString(3, txtContact.toString());
- gender = (rbtnMale.isSelected()) ? 1 :2;
- System.out.println("value of gender " + gender );
- ps.setInt(4, gender);
- int i = ps.executeUpdate();
- System.out.println("records inserted: "+i);
- sqlCon.close();
- }
- catch(Exception e)
- {
- System.out.println(e.toString());
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement