Sunday 7 July 2013

Prepared statement in oaf

  1. import java.sql.Connection;  
  2. import java.sql.PreparedStatement;  
  3. import java.sql.ResultSet;  
  4.   
  5. try  
  6.   
  7. {  
  8.   
  9.   
  10. Connection conn = pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();  
  11.   
  12. String Query = "SELECT count(*) count from XX_PA_SCO_V where project_id=:1 and CI_ID is not null";  
  13.   
  14. PreparedStatement stmt = conn.prepareStatement(Query);  
  15. stmt.setString(1, project_id);  
  16. for(ResultSet resultset = stmt.executeQuery(); resultset.next();)  
  17. {  
  18. pageContext.writeDiagnostics(this"Query Executed"1);  
  19. result = resultset.getInt("count");;  
  20. pageContext.writeDiagnostics(this"Query Executed"+ result, 1);  
  21. }  
  22. }  
  23.   
  24. catch(Exception exception)  
  25.   
  26. {   
  27. throw new OAException("Error in Staffing Query"+exception, OAException.ERROR);  
  28. }  
  29.   
  30. if(result >0)  
  31. {  
  32. throw new OAException("One or more Scope Change Order is existing on this project", OAException.INFORMATION);  
  33. }  

No comments:

Post a Comment