Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. @RequestMapping(value = "/statusCheck", method = RequestMethod.POST)
  2. public void statusCheck
  3. (
  4. @RequestParam(value = "id", defaultValue = "") String id
  5.  
  6. ) {
  7. try {
  8. StatusDao sDao = (StatusDao) context.getBean("sDao");
  9. sDao.statusLookUp(id);
  10. } catch (Throwable th) {th.printStackTrace();}
  11. }
  12.  
  13. public interface StatusDao {
  14. void statusLookUp(String id) throws DaoException;
  15. }
  16.  
  17. public class StatusDaoImpl implements StatusDao {
  18.  
  19. public void setDataSource(DataSource dataSource) {
  20. jdbcTemplate = new JdbcTemplate(dataSource);
  21. }
  22.  
  23.  
  24. @Override
  25. public void statusLookUp(String id) throws DaoException {
  26.  
  27. DataSource ds = null;
  28. Connection conn = null;
  29. PreparedStatement pstmt = null;
  30. CallableStatement cStmt = null;
  31. ResultSet rs = null;
  32.  
  33. try {
  34. ds = jdbcTemplate.getDataSource();
  35. conn = ds.getConnection();
  36. cStmt = conn.prepareCall("{call STATUS_RETRIEVER.GET_STATUS(?)}");
  37. cStmt.setString(1, id);
  38. cStmt.registerOutParameter(2, Types.VARCHAR);
  39.  
  40. int uniqueId = cStmt.getInt(2);
  41.  
  42. pstmt = conn.prepareStatement("SELECT STATUS FROM STATUS_CHECK WHERE uniqueuId=?");
  43. pstmt.setInt(1, uniqueId);
  44. rs = pstmt.executeQuery();
  45. rs.next();
  46.  
  47. String status = rs.getString("STATUS");
  48. System.out.println("The status received is as follows:");
  49. System.out.println(status);
  50.  
  51. } catch (Throwable th) {
  52. throw new DaoException(th.getMessage(), th);
  53. }
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement