??????????????濴????????????????????????????????????????????????????????????SQL INSERT/UPDATE/DELETE/SELECT ?????????
???????????£?

 

/**
*
*/
package com.sotaof.struts.db.utils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import javax.naming.InitialContext;
import javax.sql.DataSource;
/**
* @Title: DbUtils.java
* @Package com.sotaof.struts.db.utils
* @Description: TODO
* @author A18ccms A18ccms_gmail_com
* @date 2013-2-4 ????06:30:36
* @version V1.0
*/
public class DbUtils {
private static Logger logger = Logger.getLogger("DbUtils");
public static int execute(String sql?? List<Object> paramList) throws Exception
{
if(sql == null || sql.trim().equals(""))
{
logger.info("parameter is valid!");
}
Connection conn = null;
PreparedStatement pstmt = null;
int result = 0;
try
{
conn = DbUtils.getConnection();
pstmt = DbUtils.getPreparedStatement(conn?? sql);
setPreparedStatementParam(pstmt?? paramList);
if(pstmt == null)
{
return -1;
}
result = pstmt.executeUpdate();
}
catch(Exception e)
{
logger.info(e.getMessage());
throw new Exception(e);
}
finally
{
closeStatement(pstmt);
closeConn(conn);
}
return result;
}