<%@ page import="com.gauce.*,com.gauce.io.*,com.gauce.common.*,com.gauce.log.*,java.sql.*"%><%
ServiceLoader loader = new ServiceLoader(request, response);//ServiceLoader °´Ã¼¸¦ »ý¼º
GauceService service = loader.newService();//GauceService¸¦ »ý¼º
GauceContext context = service.getContext();
Logger logger = context.getLogger();

//JDBC connection Class.forName("weblogic.jdbc.pool.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:weblogic:pool:SamplePool");

try
{
Statement stmt = conn.createStatement(); GauceRequest req = service.getGauceRequest(); GauceResponse res = service.getGauceResponse(); //Client·ÎºÎÅÍ Àü¼ÛµÈ DataSet GauceDataSet userSet = req.getGauceDataSet("USER");
if (userSet != null){
//Ä®·³ÀÇ index
int idx_empno = userSet.indexOfColumn("empno"); int idx_ename = userSet.indexOfColumn("ename"); int idx_job = userSet.indexOfColumn("job");
GauceDataRow[] rows = userSet.getDataRows();
for (int j = 0; j < rows.length; j++){
//Insert
if(rows[j].getJobType() == GauceDataRow.TB_JOB_INSERT) {
String query_insert =" insert into emp (empno, ename, job) "+" values(?,?,?) "; PreparedStatement pstmt = null;
pstmt = conn.prepareStatement(query_insert);
pstmt.setInt(1, rows[j].getInt(idx_empno)); pstmt.setString(2, rows[j].getString(idx_ename)); pstmt.setString(3, rows[j].getString(idx_job));
pstmt.executeUpdate();
pstmt.close();
}
//Update
if(rows[j].getJobType() == GauceDataRow.TB_JOB_UPDATE) {
String query_update =" update emp "+" set "+" ename = ? "+" ,job = ? "+" where empno = ? ";
PreparedStatement pstmt = null;
pstmt = conn.prepareStatement(query_update);
pstmt.setString(1, rows[j].getString(idx_ename)); pstmt.setString(2, rows[j].getString(idx_job)); pstmt.setInt(3, rows[j].getInt(idx_empno));
pstmt.executeUpdate();
pstmt.close();
}
//Delete
if(rows[j].getJobType() == GauceDataRow.TB_JOB_DELETE) {
String query_delete =" delete from emp "+" where empno = ? ";
PreparedStatement pstmt = null;
pstmt = conn.prepareStatement(query_delete);
pstmt.setInt(1, rows[j].getInt(idx_empno));
pstmt.executeUpdate();
pstmt.close();
}
}
}
res.flush(); res.commit("¼º°øÀûÀ¸·Î ¸¶ÃƽÀ´Ï´Ù"); res.close();
} catch (Exception e) {
logger.err.println(this, e);
} finally {
if (conn != null) {
try {
conn.close();

} catch (Exception e) {}
}
loader.restoreService(service); }
%>