public static String format(String sql) { try { return new SQLFormatter(sql).format(); } catch (Throwable t) { return sql; } } }
public static String format(String sql) { try { return new SQLFormatter(sql).format(); } catch (Throwable t) { return sql; } } }
public boolean doDrop() { String finalSQL = sql.toString(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } sqlTemplate.update(sql.toString()); } catch (Exception e) { throw new JdbcException("Drop Table Error:" + SQLFormatter.format(finalSQL), e); } return true; }
public boolean doDrop() { String finalSQL = sql.toString(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } sqlTemplate.update(sql.toString()); } catch (Exception e) { throw new JdbcException("Drop Table Error:" + SQLFormatter.format(finalSQL), e); } return true; }
public int doUpdate() { String finalSQL = getSQL(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } return sqlTemplate.update(finalSQL, params.toArray()); } catch (SQLException e) { throw new JdbcException("Update SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public <T> T single() { String finalSQL = getSQL(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } return sqlTemplate.queryForValue(finalSQL, params.toArray()); } catch (Exception e) { throw new JdbcException("Select SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public int doDelete() { String finalSQL = getSQL(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } return sqlTemplate.delete(finalSQL, params.toArray()); } catch (SQLException e) { throw new JdbcException("Delete SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public int[] doBatchInsert() { if (params.size() == 0) { throw new JdbcException("No values"); } String finalSQL = sql.toString(); if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } try { Object[][] objects = new Object[params.size()][columnsSize]; for (int i = 0; i < params.size(); i++) { objects[i] = params.get(i); } return sqlTemplate.batchInsert(finalSQL, objects); } catch (SQLException e) { if (e.getMessage().contains("Duplicate entry")) { throw new DupEntryException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } else if (e.getMessage().contains("doesn't exist Query:")) { throw new TableNotExistException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } throw new JdbcException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } catch (Exception e) { throw new JdbcException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public int[] doBatchInsert() { if (params.size() == 0) { throw new JdbcException("No values"); } String finalSQL = sql.toString(); if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } try { Object[][] objects = new Object[params.size()][columnsSize]; for (int i = 0; i < params.size(); i++) { objects[i] = params.get(i); } return sqlTemplate.batchInsert(finalSQL, objects); } catch (SQLException e) { if (e.getMessage().contains("Duplicate entry")) { throw new DupEntryException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } else if (e.getMessage().contains("doesn't exist Query:")) { throw new TableNotExistException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } throw new JdbcException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } catch (Exception e) { throw new JdbcException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public <T> T single() { String finalSQL = getSQL(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } return sqlTemplate.queryForValue(finalSQL, params.toArray()); } catch (Exception e) { throw new JdbcException("Select SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public int doUpdate() { String finalSQL = getSQL(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } return sqlTemplate.update(finalSQL, params.toArray()); } catch (SQLException e) { throw new JdbcException("Update SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public int doDelete() { String finalSQL = getSQL(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } return sqlTemplate.delete(finalSQL, params.toArray()); } catch (SQLException e) { throw new JdbcException("Delete SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public static String format(String sql) { try { return new SQLFormatter(sql).format(); } catch (Throwable t) { return sql; } } }
public boolean doDrop() { String finalSQL = sql.toString(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } sqlTemplate.update(sql.toString()); } catch (Exception e) { throw new JdbcException("Drop Table Error:" + SQLFormatter.format(finalSQL), e); } return true; }
public int doDelete() { String finalSQL = getSQL(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } return sqlTemplate.delete(finalSQL, params.toArray()); } catch (SQLException e) { throw new JdbcException("Delete SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public int doUpdate() { String finalSQL = getSQL(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } return sqlTemplate.update(finalSQL, params.toArray()); } catch (SQLException e) { throw new JdbcException("Update SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public int[] doBatchInsert() { if (params.size() == 0) { throw new JdbcException("No values"); } String finalSQL = sql.toString(); if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } try { Object[][] objects = new Object[params.size()][columnsSize]; for (int i = 0; i < params.size(); i++) { objects[i] = params.get(i); } return sqlTemplate.batchInsert(finalSQL, objects); } catch (SQLException e) { if (e.getMessage().contains("Duplicate entry")) { throw new DupEntryException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } else if (e.getMessage().contains("doesn't exist Query:")) { throw new TableNotExistException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } throw new JdbcException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } catch (Exception e) { throw new JdbcException("Insert SQL Error:" + SQLFormatter.format(finalSQL), e); } }
public <T> T single() { String finalSQL = getSQL(); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(SQLFormatter.format(finalSQL)); } return sqlTemplate.queryForValue(finalSQL, params.toArray()); } catch (Exception e) { throw new JdbcException("Select SQL Error:" + SQLFormatter.format(finalSQL), e); } }