Anil's Blog is Best Viewed on GOOGLE CHROME

Thursday, April 16, 2009

Prepared Statement - Controller

Controller - ProcessFormRequest Code

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

try

{


Connection conn = pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();

String Query = "SELECT count(*) count from XX_PA_SCO_V where project_id=:1 and CI_ID is not null";

PreparedStatement stmt = conn.prepareStatement(Query);
stmt.setString(1, project_id);
for(ResultSet resultset = stmt.executeQuery(); resultset.next();)
{
pageContext.writeDiagnostics(this, "Query Executed", 1);
result = resultset.getInt("count");;
pageContext.writeDiagnostics(this, "Query Executed"+ result, 1);
}
}

catch(Exception exception)

{ 
throw new OAException("Error in Staffing Query"+exception, OAException.ERROR);
}

if(result >0)
{
throw new OAException("One or more Scope Change Order is existing on this project", OAException.INFORMATION);
}


1 comment:

  1. Thanks so much. It helped me to furnish one of my requirements.

    ReplyDelete

Note: Only a member of this blog may post a comment.