Help! Inserting Checkbox value into the database.
Hello,
I am trying to insert a boolean value into the database from applet-servlet communication. The code worked for once but there after it is giving exceptions. If I dont insert the boolean value into the database, then it works fine. Problem is "when I am tring to insert a boolean value into the database" . Also please help me how to check that the userid already exists in the database. It I am using only servlets and HTML it is very easy to do so, but if I wanted to use Applet-Servlet communication, how can I do this.Please see the code that I am using
//Applet side
//on click of a button
String uid = textbox1.getText().trim();
inserted = checkbox1.getState(); // boolean inserted
Insert insert = new Insert(uid,inserted); //serializable class
AppletContext ac = getAppletContext();
ac.showDocument("http://localhost:8080/Thankyou.html"):
// Serialized class
public class Insert implements Serializable
{
boolean inserted;
String uid;
public Insert(String aUid,boolean aInserted)
{
uid = aUid;
inserted = aInserted;
}
public boolean getInserted()
{
return inserted;
}
public boid getUserId()
{
return uid;
}
// Servlet side
public void doPost(HttpServletRequest request,HttpServletResponse res)
{
Insert aInsert = null;
String uid = aInsert.getUserId();
boolean check = aInsert.getInserted();
// It is printing the value of "check" also
ResultSet rs = st.executeQuery("select * from reg where userid='"+uid+"'"); //?
if(rs.next())
{
rs.close(); //How can this be done overhere as the control is in the applet button.
res.sendRedirect("http://localhost:8080/ReRegister.html");
}
else
{
int x = st.executeUpdate("insert into Checkbox values('"+uid+"','"+check+"')"); //?
}
}
datatype that I am using for check in Checkbox table is "varchar2"/"text"
Where am I wrong,Please correct me.
Thanks
Uma

