81,092
社区成员
发帖
与我相关
我的任务
分享
<%
String usee=request.getParameter("username");
String pass=request.getParameter("pwd");
String username="";
String password="";
int rns;
Class.forName("com.hxtt.sql.access.AccessDriver");
Connection conn=DriverManager.getConnection("jdbc:Access:///E:/db_database08.mdb",username,password);
Statement stmt=conn.createStatement();
if(conn!=null){out.println("数据库连接成功<BR>");}
if(stmt!=null){out.println("STMT生成成功<BR>");}
out.println("insert into tb_user(username,password) values(\""+usee+"\","+pass+")");
rns=stmt.executeUpdate("insert into tb_user(username,password) values('"+usee+"',"+pass+")");
stmt.close();
conn.close();
%>
if(stmt==null){
System.out.println("stmt为空");
}else{
System.out.println("stmt不为空");
rns=stmt.executeUpdate("insert into tb_user(username,password) values('"+usee+"',"+pass+")");
}
改成这样 看看输出什么String usee=request.getParameter("username");
String pass=request.getParameter("pwd");
String username="";
String password="";
int rns=0;//改一下这里
Class.forName("com.hxtt.sql.access.AccessDriver");
Connection conn=DriverManager.getConnection("jdbc:Access:///E:/db_database08.mdb",username,password);
Statement stmt=conn.createStatement();
if(conn!=null){out.println("数据库连接成功<BR>");}
if(stmt!=null){out.println("STMT生成成功<BR>");}
out.println("insert into tb_user(username,password) values(\""+usee+"\","+pass+")");
rns=stmt.executeUpdate("insert into tb_user(username,password) values('"+usee+"',"+pass+")");
stmt.close();
conn.close();
%>
if(stmt==null){
System.out.println("stmt为空");
}else{
System.out.println("stmt不为空");
rns=stmt.executeUpdate("insert into tb_user(username,password) values('"+usee+"',"+pass+")");
}
改成这样 看看输出什么[/quote]
我试过,就是执行stmt.executeUpdate()或者ps.executeUpdate();有问题。
用stmt.executeQuery() 方法执行SELECT语句时,都没问题,可以正常执行,没有任何错误。
之前,同样的代码,在@ayou_java那边,可以正常执行,但在我这边就会报空指针错误。我估计是不是跟系统环境,或者Access_JDBC30.jar 有关系。
我的系统环境是WIN7+JDK1.7+TOMCAT8.0,我这边的另一个机器上,环境是JDK1.8+ECLIPSE也有类似的情况,我们两台机器相同点是用的同一个的Access_JDBC30.jar拷贝文件 。所以,后面再重下个Access_JDBC30.jar包试试,如果问题还这样,只能说明我的RP有问题