jsp不能向mysql中添加数据是什么原因啊?很急 帮忙解决一下 谢了、、
<%StringID="";StringName=request.getParameter("Name");Stringmydate=newSimpleDateForma...
<%
String ID="";
String Name=request.getParameter("Name");
String mydate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
String Addtime=request.getParameter("mydate");
String Url=request.getParameter("Url");
String sendtime=request.getParameter("sendtime");
String demo="";
String opennumber="";
String clicknumber="";
try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
}catch(ClassNotFoundException e){}
try{
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/chinasignstest","root","123");
Statement stm =con.createStatement();
String sql="insert into edmlist values('"+ID+"','"+Name+"','"+Addtime+"','"+Url+"','"+sendtime+"','"+demo+"','"+opennumber+"','"+clicknumber+"')";
//System.out.print("11111111");
System.out.print(sql);
stm.executeUpdate(sql);
out.print("添加成功!!");
System.out.print("11111111");
con.close();
}catch(SQLException e1){}
%> 展开
String ID="";
String Name=request.getParameter("Name");
String mydate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
String Addtime=request.getParameter("mydate");
String Url=request.getParameter("Url");
String sendtime=request.getParameter("sendtime");
String demo="";
String opennumber="";
String clicknumber="";
try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
}catch(ClassNotFoundException e){}
try{
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/chinasignstest","root","123");
Statement stm =con.createStatement();
String sql="insert into edmlist values('"+ID+"','"+Name+"','"+Addtime+"','"+Url+"','"+sendtime+"','"+demo+"','"+opennumber+"','"+clicknumber+"')";
//System.out.print("11111111");
System.out.print(sql);
stm.executeUpdate(sql);
out.print("添加成功!!");
System.out.print("11111111");
con.close();
}catch(SQLException e1){}
%> 展开
3个回答
2010-08-23
展开全部
改成Class.forName("com.mysql.jdbc.Driver");
也不行 我的数据顺序没问题啊
错误信息:
org.apache.jasper.JasperException: Exception in JSP: /insert.jsp:53
50: //out.print("添加成功!!");
51: System.out.print(sql);
52: //System.out.print("11111111");
53: stm.executeUpdate(sql);
54: //System.out.print(sql);
55: System.out.print("11111111");
56: con.close();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
javax.servlet.ServletException: Incorrect decimal value: '' for column 'opennumber' at row 1
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
java.sql.SQLException: Incorrect decimal value: '' for column 'opennumber' at row 1
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
com.mysql.jdbc.Connection.execSQL(Connection.java:3250)
com.mysql.jdbc.Statement.executeUpdate(Statement.java:1355)
com.mysql.jdbc.Statement.executeUpdate(Statement.java:1270)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
也不行 我的数据顺序没问题啊
错误信息:
org.apache.jasper.JasperException: Exception in JSP: /insert.jsp:53
50: //out.print("添加成功!!");
51: System.out.print(sql);
52: //System.out.print("11111111");
53: stm.executeUpdate(sql);
54: //System.out.print(sql);
55: System.out.print("11111111");
56: con.close();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
javax.servlet.ServletException: Incorrect decimal value: '' for column 'opennumber' at row 1
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
java.sql.SQLException: Incorrect decimal value: '' for column 'opennumber' at row 1
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
com.mysql.jdbc.Connection.execSQL(Connection.java:3250)
com.mysql.jdbc.Statement.executeUpdate(Statement.java:1355)
com.mysql.jdbc.Statement.executeUpdate(Statement.java:1270)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你确定mysql的加载驱动是这么写的吗?
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
你试试这个,
Class.forName("com.mysql.jdbc.Driver");
还有插不进去,没报什么错吗?
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
你试试这个,
Class.forName("com.mysql.jdbc.Driver");
还有插不进去,没报什么错吗?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
错误是什么?
检查一下你插入数据的顺序和数据库中的列的顺序是否一致~~~~~~~
检查一下你插入数据的顺序和数据库中的列的顺序是否一致~~~~~~~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询