Map parameter = new HashMap(); parameter.put("table", "sales2009"); parameter.put("date", "2009-10-08"); //MySQL date :) parameter.put("product_id",17); SqlMapClient sqlMap = (SqlMapClient) getServletContext().getAttribute("sqlMap"); List result = sqlMap.queryForList("selectSalesByParameters",parameter); for(Sales s : result) { }
public Object delete(String id, Object entity) { try { sqlMapClient.delete(id, entity); } catch (SQLException e) { throw new DaoException("Exception throw while executing delete with statement id '" + id + "' and entity '" + entity + "'", e); } return null; }
/** * If no DataSource specified, use SqlMapClient's DataSource. * @see com.ibatis.sqlmap.client.SqlMapClient#getDataSource */ public DataSource getDataSource() { DataSource ds = super.getDataSource(); return (ds != null ? ds : this.sqlMapClient.getDataSource()); }
Map<String, Object> attributeMap = getAttributesMap(lm.getLscAttributeModifications()); try { sqlMapper.startTransaction(); switch(lm.getOperation()) { case CHANGE_ID: for(String request: getRequestsNameForInsert()) { LOGGER.debug("Executing " + request + "(" + attributeMap + ")"); sqlMapper.insert(request, attributeMap); for(String request: getRequestsNameForDelete()) { LOGGER.debug("Executing " + request + "(" + attributeMap + ")"); sqlMapper.delete(request, attributeMap); for(String request: getRequestsNameForUpdate()) { LOGGER.debug("Executing " + request + "(" + attributeMap + ")"); sqlMapper.update(request, attributeMap); sqlMapper.commitTransaction(); } catch (SQLException e) { LOGGER.error(e.toString(), e); } finally { try { sqlMapper.endTransaction(); } catch (SQLException e) { LOGGER.error(e.toString(), e);
dataSource == this.sqlMapClient.getDataSource()) { logger.debug("Executing action directly on SqlMapClient"); try { SqlMapSession session = this.sqlMapClient.openSession(); try { Connection con = DataSourceUtils.getConnection(getDataSource());
protected Object executeWith(DataSource dataSource, SqlMapClientCallback action) { SqlMapSession session = getSqlMapClient().openSession();
public Object update(String id, Object entity) { try { sqlMapClient.update(id, entity); } catch (SQLException e) { throw new DaoException("Exception throw while executing update with statement id '" + id + "' and entity '" + entity + "'", e); } return null; }
public Object insert(String id, Object entity) { try { sqlMapClient.insert(id, entity); } catch (SQLException e) { throw new DaoException("Exception throw while executing insert with statement id '" + id + "' and entity '" + entity + "'", e); } return null; }
protected Object executeWith(Connection connection, SqlMapClientCallback action) { SqlMapSession session = getSqlMapClient().openSession(); try { try { session.setUserConnection(connection); } catch (SQLException e) { throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", e); } try { return action.doInSqlMapClient(session); } catch (SQLException ex) { throw new SQLErrorCodeSQLExceptionTranslator().translate("SqlMapClient operation", null, ex); } } finally { session.close(); } }
public Object update(String id, Object entity) { try { sqlMapClient.update(id, entity); } catch (SQLException e) { throw new DaoException("Exception throw while executing update with statement id '" + id + "' and entity '" + entity + "'", e); } return null; }
public Object insert(String id, Object entity) { try { sqlMapClient.insert(id, entity); } catch (SQLException e) { throw new DaoException("Exception throw while executing insert with statement id '" + id + "' and entity '" + entity + "'", e); } return null; }
@SuppressWarnings("unchecked") public Collection<Object> lookup(String id, Map<String, ?> parameters) { try { return sqlMapClient.queryForList(id, parameters); } catch (SQLException e) { throw new DaoException("Exception throw while executing query with statement id '" + id + "' and parameters '" + parameters + "'", e); } }
private DataSource findDataSourceToUse(String key) { DataSource dataSourceToUse = null; if (StringUtils.equals(key, getDefaultDataSourceName())) { dataSourceToUse = getSqlMapClient().getDataSource(); } else { dataSourceToUse = getCobarDataSourceService().getDataSources().get(key); } return dataSourceToUse; }
public void performIndex(CompassSession session, IndexEntity[] entities) throws CompassException { for (IndexEntity entity : entities) { SqlMapIndexEntity indexEntity = (SqlMapIndexEntity) entity; SqlMapSession sqlMapSession = getSqlMapClient().openSession(); try { sqlMapSession.startTransaction(); if (log.isDebugEnabled()) { log.debug(buildMessage("Indexing select statement id [" + indexEntity.getStatementId() + "]")); } sqlMapSession.queryWithRowHandler(indexEntity.getStatementId(), indexEntity.getParam(), new SqlMapClientGpsDeviceRowHandler(indexEntity, session, pageSize)); session.evictAll(); sqlMapSession.commitTransaction(); } catch (SQLException e) { throw new SqlMapGpsDeviceException("Failed to fetch paginated list for statement [" + indexEntity.getStatementId() + "]", e); } finally { try { try { sqlMapSession.endTransaction(); } catch (Exception e) { log.warn(buildMessage("Failed to close sqlMap session, ignoring"), e); } } finally { sqlMapSession.close(); } } } } }
public Object delete(String id, Object entity) { try { sqlMapClient.delete(id, entity); } catch (SQLException e) { throw new DaoException("Exception throw while executing delete with statement id '" + id + "' and entity '" + entity + "'", e); } return null; }
@SuppressWarnings("unchecked") public Collection<Object> lookup(String id, Map<String, ?> parameters) { try { return sqlMapClient.queryForList(id, parameters); } catch (SQLException e) { throw new DaoException("Exception throw while executing query with statement id '" + id + "' and parameters '" + parameters + "'", e); } }
/** * FIXME * * @throws SQLException */ void testConnection() throws SQLException { BusinessDAOImpl dao = (BusinessDAOImpl) getBusinessDAO(); DataSource ds = dao.getSqlMapClientTemplate().getSqlMapClient() .getDataSource(); Connection conn = ds.getConnection(); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("select * from man_tb_monitoruser"); DataBaseUtils.closeConnection(rset, stmt, conn); }
@SuppressWarnings("unchecked") public Collection<Object> lookup(String id, Object ... parameters) { try { return sqlMapClient.queryForList(id, parameters); } catch (SQLException e) { throw new DaoException("Exception throw while executing query with statement id '" + id + "' and parameters '" + parameters + "'", e); } }
statementName, parameterObject); if (MapUtils.isEmpty(resultDataSources) || resultDataSources.size() == 1) { targetDataSource = getSqlMapClient().getDataSource(); // fall back to default data source. if (resultDataSources.size() == 1) { targetDataSource = resultDataSources.values().iterator().next();
@SuppressWarnings("unchecked") public Collection<Object> lookup(String id, Object ... parameters) { try { return sqlMapClient.queryForList(id, parameters); } catch (SQLException e) { throw new DaoException("Exception throw while executing query with statement id '" + id + "' and parameters '" + parameters + "'", e); } }