我主要想用PreparedStatement
String strSql="insert into tbl_phone values(?)";
String strSql1="update tbl_user set userName=?";
给sql动态赋值,但好像有错,请如果用PreparedStatement来操作具体怎么写
String strSql="insert into tbl_phone values(?)";
String strSql1="update tbl_user set userName=?";
给sql动态赋值,但好像有错,请如果用PreparedStatement来操作具体怎么写
解决方案 »
- Spring schedule定时器中,报错hibernate could not initialize proxy - no Session
- ???
- 我想做一个个人网站,请问怎么弄?
- 用eclipse3.2打开一个已有的工程时提示: 'com.genuitec.eclipse.j2eedt.core.J2EE14_CONTAINER(未知)'
- 求救:如何将JavaScript生成的动态表格里删除的值提交到Servlet里进行删除?
- unicode,GBK,ISO8859-1编码方式有什么区别啊!
- 大家来看一下我的思路对不对,可行不?急
- 在JavaMail发送或接受邮件时pop3、smtp服务器名如何填写
- 请问,MultipartRequest怎么用啊!
- jsp_struts问题!
- Java大菜鸟,问如何用servlet在html页面上画图和刷新自己的问题
- JSP工程在myeclipse中能运行,为什么单独启动tomcat就不能运行了??在线等!!!!
Statement stmt = connection.createStatement();
sql = "DELETE FROM my_table WHERE col_string=?";
PreparedStatement pstmt = connection.prepareStatement(sql);
pstmt.setString(1, "a string");
deleteCount = pstmt.executeUpdate();
pstmt.setString(1, "a string");
如果是整形的参数的话
pstmt.setInt(1, 1);
String strSql1="update tbl_user set userName=?";
给sql动态赋值,但好像有错,请如果用PreparedStatement来操作具体怎么写
conn.setAutoCommit(false);
String strSql="insert into tbl_phone values(?)";
String strSql1="update tbl_user set userName=?";
conn.commit();
两条sql语句PreparedStatement(预编译)动态赋值
在定义一个PreparedStatement pstmt = connection.prepareStatement(sql1); 吗。
Statement stmt = connection.createStatement();
sql = "insert into tbl_phone values(?);update tbl_user set userName=?";
PreparedStatement pstmt = connection.prepareStatement(sql);
pstmt.setString(1, "a string");
pstmt.setString(2, "b string");
deleteCount = pstmt.executeUpdate(); 你这样试试嘛
sql和sql1不写在一起