既然是update怎么可能返回记录集rs1
解决方案 »
- 大家项目开发时一般怎么做权限的管理的 ?
- request.getRequestDispatcher页面跳转问题,真心求教 ,谢谢在线等
- 用EL语言取struts2下action里面的bean的值的问题
- 关于tomcat静态变量的问题,有哪位高人帮我解决下
- 修改了class竟导致404错误
- 求一个算法,要求高效
- [软件测试]老大给了一份测试建议,本人测试菜鸟,发到此区希望各位朋友帮忙~~
- 关于从JavaScript中将值取到JSP脚本的变量中的问题,急
- 偶是新手,问问谁知道这样的结果会是什么??
- {200分}利用ResultSetMetaData meta1=rs2.getMetaData(),取表信息int y=meta1.getColumnCount(),出现怪问题?前面可以,往后就不行
- 关于日期的,老是出错,请赐教!
- 我安装的jbuilder 8没有帮助文档,大家用的有吗?
stmt.executeUpdate(sql);
//executeUpdate(sql);用于更新(update,insert,delete)
或者接受返回的一个INT型的值,表明UPDATE了多少条数据。
没注意,丢人丢人。
update 返回是int型的。
定义的是read可是现在在外面手头没资料,忘了可更新连接的参数了那位大瞎帮忙给查一下,谢谢
public ResultSet executeQuery(String sql)
throws SQLException
Executes the given SQL statement, which returns a single ResultSet object.Parameters:sql - an SQL statement to be sent to the database, typically a static SQL SELECT statementReturns:a ResultSet object that contains the data produced by the given query; never null
public int executeUpdate(String sql)
throws SQLException
Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.Parameters:sql - an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothingReturns:either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
exp2="update students set pwd='"+newpwd+"' where studentid='"+studentid+"'";
rs1 = shen.executeQuery(exp2);//here 改成shen.executeUpdate(exp2);
}
catch(Exception e){
out.println("error:"+e);
}
Connection con = null;
Statement shen = null;
con= tjwy.getConnection(); //tjwy为一个连接数据库的been,肯定没问题
shen=con.createStatement(conrs.TYPE_SCROLL_INSENSITIVE,conrs.CONCUR_READ_ONLY);
try{
exp2="update students set pwd='"+newpwd+"' where studentid='"+studentid+"'";
shen.executeQuery(exp2);
}
catch(Exception e){
out.println("error:"+e);
}
以上语句还是有问题,我觉得就是shen = con.createStatement(.....,...._READ_ONLY)这句有问题那位老兄帮忙给查一下,拜托...
public Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws SQLException
Creates a Statement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the createStatement method above, but it allows the default result set type and concurrency to be overridden. Parameters:
resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
Returns:
a new Statement object that will generate ResultSet objects with the given type and concurrency
Throws:
SQLException - if a database access error occurs or the given parameters are not ResultSet constants indicating type and concurrency
Since:
1.2 是不是这个?
应该改为:rs1=shen.executeUpdate(exp2);