社区
Web 开发
帖子详情
今天最后一个问题!关于executeUpdate的,在线等侍!顶者有分
pdw2009
2004-08-24 04:18:44
现在要修改数据库里的某条记录我不想用PreparedStatement,能不能直接用executeUpdate来更新呢
如果能,请你给出一条executeUpdate的例子,如果不能,请你给出PreparedStatement的使用方法。
谢谢,大家的关照真,没有csdn的朋友,可能我无法进行这个行业。。。
...全文
405
10
打赏
收藏
今天最后一个问题!关于executeUpdate的,在线等侍!顶者有分
现在要修改数据库里的某条记录我不想用PreparedStatement,能不能直接用executeUpdate来更新呢 如果能,请你给出一条executeUpdate的例子,如果不能,请你给出PreparedStatement的使用方法。 谢谢,大家的关照真,没有csdn的朋友,可能我无法进行这个行业。。。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
10 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
power17
2004-08-24
打赏
举报
回复
不会是单引号或是其它什么地方出错了吧。
建议先把SQL语句写在查询分析器上运行一下,运行无误后放到jsp中去。
aoplo
2004-08-24
打赏
举报
回复
prepareStatement方式:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:user_db";
Connection con=DriverManager.getConnection(url,"insher","insher");
PreparedStatement stm=con.prepareStatement("insert into message values(?,?,?,?,?)");
stm.setString(1,title);
stm.setString(2,name);
stm.setString(3,mail);
stm.setString(4,datetime);
stm.setString(5,content);
建议用executeUpdate方式!
pdw2009
2004-08-24
打赏
举报
回复
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection conn=null;
try{
//Connection conn=DriverManager.getConnection("jdbc:mysql://localhost/test");
conn=DriverManager.getConnection("jdbc:mysql://192.168.0.217/courthouse?user=root&password=&useUnicode=true&characterEncoding=");
}catch(Exception e){
System.out.println("ERROR"+e);
}
PreparedStatement pstmt=conn.PreparedStatement("update b_ryxx set MC=?,YX=?,ISFJY=?,XCBM=?,password=? where DM=?");
%>
这是我原来写的,但却出现以下错误,大家看看是什么原因
----------------------------------------------------------------
symbol : method PreparedStatement (java.lang.String)
location: interface java.sql.Connection
PreparedStatement pstmt=conn.PreparedStatement("update b_ryxx set MC=?,YX=?,ISFJY=?,XCBM=?,password=? where DM=?");
aoplo
2004-08-24
打赏
举报
回复
<jsp:useBean id="wu" scope="page" class="conn.jdbc" />//数据库连接bean
<%
Connection con = wu.getConn();
Statement stmt = con.createStatement() ;
String sql = ".............";
ResultSet rs = stmt.executeUpdate(sql) ;
%〉
wangwei8117
2004-08-24
打赏
举报
回复
sql="update dbName set xx='abc' where xx=?
stmt.execute(sql);就可以,不容易出现错误的!
runningww
2004-08-24
打赏
举报
回复
当然可以了
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433";
Connection con = null;
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection(url,"sa","");
Statement stmt = con.createStatement();
stmt.executeUpdate(sql);
zyfdanny
2004-08-24
打赏
举报
回复
Connection con = DriverManager.getConnection("jdbc:odbc:dbname","","");
Startement stmt = con.CreateStatement();
stmt.executeUpdate("update table set xx =xx");
con.close();
一点晴
2004-08-24
打赏
举报
回复
PreparedStatement的使用方法:
sql="update books set price=? where id=?";//例子SQL语句更新某本书的价格
PreparedStatement pst=conn.prepareStatement(sql);
pst.setInt(1,"20");//对应SQL中第1个?如果是字符串型数据则是.setString() 看API文档
pst.setInt(2,"133");////对应SQL中第2个?
pst.executeUpdate();
pst.close();
一点晴
2004-08-24
打赏
举报
回复
非预便宜的statement
Statement st=conn.createStatement();
st.executeUpdate(sql);
pdw2009
2004-08-24
打赏
举报
回复
期侍中,,,,
关于
execute
Update
方法返回的值
问题
今天
在项目中出现了
一个
问题
,delete 语句使用
execute
Update
方法后,如果是更新一条数则返回1,但是更新一条以上数据就出现返回0的
问题
,我一直以为
execute
Update
返回更新的条数是错误的?带着疑问我们查看源码: @...
关于
execute
Update
()返回值
问题
今天
debug的时候发现使用truncate的时候
execute
Update
()的返回值是0,让我十分费解,因为之前使用
update
语句debug出来的返回值是需要更新的条数,后来问了群里老哥,老哥说是因为truncate是DDL语句,返回值为0时表示...
execute
Update
()返回值
execute
Update
()是PreparedStatement对象众多的抽象方法中的
一个
在jdk1.8中
execute
Update
()有两种返回值(搜索一下 PreparedStatement 即可查看到),即有两种返回值不同的方法。返回值分别是:int 和ResultSet 在...
execute
、
execute
Query、
execute
Update
三者之间有什么区别
文章目录
execute
、
execute
Query、
execute
Update
三者之间有什么区别
execute
Query
execute
Update
execute
execute
、
execute
Query、
execute
Update
三者之间有什么区别
execute
Query 用于产生单个结果集语句(ResultSet),...
execute
Update
方法
execute
Update
用于执行 INSERT、
UPDATE
或 DELETE 语句以及 SQL DDL(数据定义语言)语句,例如 CREATE TABLE 和...
execute
Update
的返回值是
一个
整数(int),指示受影响的行数(即更新计数)。对于 CR
Web 开发
81,091
社区成员
341,719
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章