Hibernate获取Connection 方法:

Hibernate3获取Connection 方法:

Connection connection = this.getSession().connection();
String procedure = "{call proc_QSDZDZZZZZ(?)}";
CallableStatement cstmt = connection.prepareCall(procedure);
// 设置参数
cstmt.registerOutParameter(1, java.sql.Types.INTEGER);


Hibernate4获取Connection 方法:

final Integer[] result = new Integer[1];
this.getSession().doWork(new Work() {
	@Override
	public void execute(Connection connection) throws SQLException {
			String procedure = "{call proc_QSDZDZZZZZ(?)}";
			CallableStatement cstmt = connection.prepareCall(procedure);
			// 设置参数
			cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
			result[0] = cstmt.getInt(1);
			cstmt.close();
		}
	});

 

你可能感兴趣的:(Hibernate)