Connection conn=null; CallableStatement cstmt=null; try{ conn=this.getConnection(); cstmt =conn.prepareCall("{call delPro(?)}"); cstmt.setInt(1, 2); boolean tag=cstmt.execute(); System.out.println(" 删除成功"); }catch(Exception e){e.printStackTrace();} finally{ if(cstmt!=null){ cstmt.close(); } if(conn!=null){ conn.close(); } } } public static void main(String [] args) throws SQLException{ Test tset =new Test(); } }
四、Hibernate JDBC中使用
4.1 在数据库中创建存储过程;
4.2 在hibernate 中配置存储过程,以及返回的对象
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-
-
- <hibernate-mapping>
- <class name="com.test.hibernate.TableTest" table="table_test"
|