第十五讲Java数据库连接.pptVIP

  • 2
  • 0
  • 约9.49千字
  • 约 49页
  • 2017-07-29 发布于北京
  • 举报
第十五讲Java数据库连接

补充:基本概念 2)执行方法如下: executeQuery,executeUpdate,execute具体使用如下: String tsql=“select name,age from table1”; ResultSet rs=stmt.executeQuery(tsql); 非select语句如:int nRet= stmt.executeUpdate(tsql); execute方法用于:返回多个结果集。 3)关闭:close stmt.close(); 补充:基本概念 2、PreparedStatement 通过PreparedStatement可以将SQL语句预编译,还可以内嵌参数进行预编译具体使用如下: String tsql=“Select * from table1 where id=”+nID+” and name=‘”+strName+”’”; 或:PreparedStatement ps=con.preparedStatement(“delete from table1 where id=? And name=?”); ps.setInt(1,nID); ps.setString(2,strName); ps.execute

文档评论(0)

1亿VIP精品文档

相关文档