Java EE 应用中对前端用户的数据库操作的审计
2010-09-26 00:00:00 来源:WEB开发网清单 6. 一个自定制的 SqlMapClient 实现
public class MySqlMapClient implements SqlMapClient{
SqlMapClient sqlMap ;
public MySqlMapClient(SqlMapClient sqlMap) {
this.sqlMap = sqlMap ;
}
public Object insert(String id, Object parameterObject) throws SQLException {
Object retObj = null ;
OracleDataSource dataSource = null ;
OracleConnection conn = null ;
try {
conn = (OracleConnection)dataSource.getConnection();
SqlMapSession session = sqlMap.openSession(conn);
conn.setClientIdentifier("") ;
sqlMap.setUserConnection(conn) ;
retObj = session.insert(id, parameterObject) ;
conn.clearClientIdentifier("") ;
conn.commit() ;
} catch (Exception e) {
// TODO: handle exception
} finally {
try {
conn.close() ;
} catch (Exception e2) {
// TODO: handle exception
}
}
return retObj ;
}
//other methods … .
}
更多精彩
赞助商链接