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

[2135 byte] By [reddyumamaheswar] at [2007-9-26 8:18:13]
# 1
getState() return true;you might need to insert 0 or 1public int getCheck(){return (check)?1:0;}
jef06 at 2007-7-1 18:49:47 > top of Java-index,Desktop,Core GUI APIs...
# 2
Hi, Thanks for your reply.I tried it that way also, but it worked for the first time, but there after it is giving me exceptions. Any another answer pleaseRegardsUma
reddyumamaheswar at 2007-7-1 18:49:47 > top of Java-index,Desktop,Core GUI APIs...
# 3
Could you post the exception and its stack trace rather than relying on my uncanny soothsaying skills?
KPSeal at 2007-7-1 18:49:47 > top of Java-index,Desktop,Core GUI APIs...