请更正jsp代码以将数据插入到访问数据库中 [英] please correct the jsp code to insert data into acess DB

查看:107
本文介绍了请更正jsp代码以将数据插入到访问数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Statement stmt=con.createStatement();
try
{
stmt.executeUpdate("insert into smstable values('"+message+"','"+no+"')");
out.println(" sucessfull");
}catch(Exception e)
{
	out.println("not inserted");


}

推荐答案

您提供的信息不多,因此只是猜测可能是什么问题.我注意到第二个参数称为否".如果否"为数字,则您的陈述应如下所示:

You do not provide much information, so it''s just guessing what the problem could be. I noticed that the second parameter is called ''no''. If ''no'' is numeric your statement should look like this:

stmt.executeUpdate("insert into smstable values(''"+message+"'',"+no+")");



另一种可能性是一个或多个值超出了字段大小限制.


如果那不是问题,则在catch块中添加以下行:

out.println(e.Message);

或查看innerexception(如果有)以获取更多信息,并使用其他信息更新您的问题.



Another possibility is that one or more values exceed the fieldsize limit.


If that is not the problem then add the following line in the catch block:

out.println(e.Message);

or look at the innerexception (if available) for more information and update your question with the extra information.


这篇关于请更正jsp代码以将数据插入到访问数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆