将值插入表格时遇到问题

时间:2013-12-04 12:46:31

标签: jsp jdbc javabeans

<%
String cusId = request.getParameter("UserName");
String cusPwd = request.getParameter("Pwd");
String dChoc = request.getParameter("dChoc");
String wChoc = request.getParameter("wChoc");
String sToys = request.getParameter("sToys");
String bdayCard = request.getParameter("bdayCard");
String weddCard = request.getParameter("weddCard");
String bigOrna = request.getParameter("bigOrna");
String smallOrna = request.getParameter("smallOrna");
String candle = request.getParameter("candle");
String keyCha = request.getParameter("keyCha");
String tow = request.getParameter("tow");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:customer_data");

Statement s = con.createStatement();
try{
int status = 0;
//error here
    status = s.executeUpdate("INSERT INTO Table1 (Soft_Toys,Dark_Chocolate,White_Chocolate,Birthday_Card,Wedding_card,Big_Ornaments,Small_Ornaments,Candles,KeyChain,Customer_Id,Customer_pw,Towels)"+ "values('"+sToys+"','"+dChoc+"','"+wChoc+"','"+bdayCard+"','"+weddCard+"','"+bigOrna+"','"+smallOrna+"','"+candle+"','"+keyCha+"','"+cusId+"','"+cusPwd+"','"+tow+"')");
}
catch
if(status>0)
System.out.println("Update successful");
else
System.out.println("Error!!!");


s.close();
con.close();

%GT;

0 个答案:

没有答案