jsp将表单数据提取添加到mysql数据库出现错误.."int rowCount=pStmt.executeUpdate(); "到此句出现问题

jsp将表单数据提取添加到mysql数据库出现错误.."int rowCount=pStmt.executeUpdate(); "到此句出现问题,第1张

你前面这样定义的PreparedStatement pStmt=connectionprepareStatement(sql);

后面你又用pStmtexecuteQuery("Select from teacher");

这明显冲突了啊,你用insert语句构建的PreparedStatement,后来又查询,当然报错了

如果你的处理页面就是指 functionjsp 这个的话 那应该是你没有解码 所以你的数据全是乱码 而你的数据库代码又没有错误只是搜索不到结果 那很显然 什么都没有 很正常 ,你试着在你获取到上个页面参数前 加上这段代码 requestsetCharacterEncoding("gb2312"); 进行解码 我想应该就可以了!

rs1=psexecuteInsert(sql);

插入应该用executeUpdate

The method executeInsert(String) is undefined for the type PreparedStatement

PreparedStatement中找不到方法executeInsert(String)。

插入、删除、更改用executeUpdate,查询用executequery

你好,应该是数据库连接配置没有对。

要根据实现情况修改JSP配置文件里的数据库连接信息(IP、用户名、密码、数据库、端口)等信息。

因为你的网站源码可的读出来,说明JDK和TomCat本身配置配置没对,而数据库也架设好的话,那就只能是数据库连接问题,或者是数据库里没有信息吧。

看看你的程序是不是需要安装,或者是不是要导入数据库(sql文件)。

哪有你这样写程序的,所有的处理代码都写在jsp里,所有人都想着尽量让jsp里没java代码呢!

处理代码写到servlet文件中,jsp用jstl标签显示就行了!

500错误是服务器响应错误,你把错误贴出来看看

首先是数据库连接代码类:

然后在你的jsp页面写上调用数据连接类的增删改查就可以了。

不懂hi我

jsp页面中

<%

String sqlgetServiceId="select eid from eip_service e where eservice_name_en='"+serviceNamesubstring(serviceNamelastIndexOf("_")+1)+"' and eservice_version=10";

int sid=BaseDBqueryId(sqlgetServiceId, null);

%>

BaseDBjava

import javasqlConnection;

import javasqlDriverManager;

import javasqlPreparedStatement;

import javasqlResultSet;

import javasqlSQLException;

import javautilregexMatcher;

import javautilregexPattern;

public class BaseDB {

public static String URL = "jdbc:oracle:thin:@192168174189:1521:soadb"; //版本管理ERP数据库配置

public static String NAME = "SVMDEV";//用户名

public static String PWD = "SVMPWD";//密码

public static PreparedStatement ps =null;

public static ResultSet rs =null;

public static Connection connection=null;

//获取数据库连接信息

public static Connection getConnection() {

try {

ClassforName("oraclejdbcOracleDriver");

if (connection==null) {

connection=DriverManagergetConnection(URL, NAME, PWD);

}

} catch (ClassNotFoundException e) {

eprintStackTrace();

} catch (SQLException e) {

eprintStackTrace();

}

return connection;

}

//查询数据,根据相关信息查询得到当前服务的某个需要的id

public static int queryId(String sql,String parameter[] ) {

int getId=0;

try {

connection=getConnection();

ps=connectionprepareStatement(sql);

if (parameter!=null) {

for (int i = 1; i <=parameterlength; i++) {

pssetString(i,parameter[i-1]);

}

}

rs=psexecuteQuery();

if(rsnext()&&rs!=null){

getId=rsgetInt(1);

}

} catch (SQLException e) {

eprintStackTrace();

}finally{

closeAll(ps, rs, connection);

}

return getId;

}

//修改数据

public static int updateData(String sql,String parameter[] ) {

int count=0;

try {

connection=getConnection();

ps=connectionprepareStatement(sql);

if (parameter!=null) {

for (int i = 1; i <=parameterlength; i++) {

pssetString(i,parameter[i-1]);

}

}

count=psexecuteUpdate();

} catch (SQLException e) {

eprintStackTrace();

}finally{

closeAll(ps, rs, connection);

}

return count;

}

//插入数据

public static int insertData(String sql,String parameter[]) {

int num=0;

try {

connection=getConnection();

ps=connectionprepareStatement(sql);

if (parameter!=null) {

for (int i = 0; i <parameterlength; i++) {

pssetString(i+1,parameter[i]);

}

}

num=psexecuteUpdate();

} catch (Exception e) {

eprintStackTrace();

}finally{

closeAll(ps,null,connection);

}

return num;

}

//关闭所有

public static void closeAll(PreparedStatement ps,ResultSet rs,Connection connection) {

try {

if (ps!=null) {

psclose();

}

} catch (Exception e2) {

try {

if (rs!=null) {

rsclose();

rs=null;

}

} catch (Exception e3) {

try {

if (connection!=null) {

//connectionclose();

//connection=null;

}

} catch (Exception e4) {

e4printStackTrace();

}

}

}

}

}

以上就是关于jsp将表单数据提取添加到mysql数据库出现错误.."int rowCount=pStmt.executeUpdate(); "到此句出现问题全部的内容,包括:jsp将表单数据提取添加到mysql数据库出现错误.."int rowCount=pStmt.executeUpdate(); "到此句出现问题、在jsp页面中,想往数据库里面插入数据,tomcat不显示报错,但是却在数据库中查不到插入的数据、JSP数据库插入问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/10142008.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存