java中调用package

具体代码如下:

	public String executeSyncUser(String operator) throws Exception {
		Connection conn = createConnection();
		String flag = "1";

		CallableStatement stmt = conn.prepareCall("{call syncUser(?,?)}");

		// stmt.setLong(1, operator);
		stmt.setFloat(1, Float.valueOf(operator));
		stmt.registerOutParameter(2, Types.VARCHAR); 

		// stmt.setInt(2, flag);
		try {
			System.out.println("用同步开始时间" + System.currentTimeMillis());
			log.info("用户同步开始时间" + new Date(System.currentTimeMillis()));
			stmt.execute();
			flag = stmt.getString(2);
			conn.commit();
			System.out.println("用户同步结束时间" + System.currentTimeMillis());
			log.info("用户同步结束时间" + new Date(System.currentTimeMillis()));
		} catch (Exception e) {
			conn.rollback();
			throw e;
		} finally {
			try {
				if (stmt != null) {
					stmt.close();
				}
				if (conn != null) {
					releaseConnection(conn);
				}
			} catch (Exception e) {
				throw e;
			}
		}
		return flag;
	}

猜你喜欢

转载自weigang-gao.iteye.com/blog/2243332