Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RequestMapping(value = "/statusCheck", method = RequestMethod.POST)
- public void statusCheck
- (
- @RequestParam(value = "id", defaultValue = "") String id
- ) {
- try {
- StatusDao sDao = (StatusDao) context.getBean("sDao");
- sDao.statusLookUp(id);
- } catch (Throwable th) {th.printStackTrace();}
- }
- public interface StatusDao {
- void statusLookUp(String id) throws DaoException;
- }
- public class StatusDaoImpl implements StatusDao {
- public void setDataSource(DataSource dataSource) {
- jdbcTemplate = new JdbcTemplate(dataSource);
- }
- @Override
- public void statusLookUp(String id) throws DaoException {
- DataSource ds = null;
- Connection conn = null;
- PreparedStatement pstmt = null;
- CallableStatement cStmt = null;
- ResultSet rs = null;
- try {
- ds = jdbcTemplate.getDataSource();
- conn = ds.getConnection();
- cStmt = conn.prepareCall("{call STATUS_RETRIEVER.GET_STATUS(?)}");
- cStmt.setString(1, id);
- cStmt.registerOutParameter(2, Types.VARCHAR);
- int uniqueId = cStmt.getInt(2);
- pstmt = conn.prepareStatement("SELECT STATUS FROM STATUS_CHECK WHERE uniqueuId=?");
- pstmt.setInt(1, uniqueId);
- rs = pstmt.executeQuery();
- rs.next();
- String status = rs.getString("STATUS");
- System.out.println("The status received is as follows:");
- System.out.println(status);
- } catch (Throwable th) {
- throw new DaoException(th.getMessage(), th);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement