时间:2021-07-01 10:21:17 帮助过:2人阅读
调用存储过程插入语句:
public int insertStu(String sname,String ssex) throws Exception { Connection con = Dbhelper.getconnection(); PreparedStatement ps = null; int result = -1; if(con!=null) { try { //String sql = "exec indata(‘"+sname+"‘,‘"+ssex+"‘)"; //这样是不行的 String sql = "{call indata(‘"+sname+"‘,‘"+ssex+"‘)}"; //应该写成这样 System.out.println(sql); ps = con.prepareCall(sql); ps.executeUpdate(); con.close(); } catch(Exception ex) { System.out.println(ex); } finally{ try { ps.close(); } catch(Exception ex1) { System.out.println(ex1); } } } return result; }
使用JDBC调用存储过程
标签: