/** * Creates a select distinct prepared statement * * @param dp The DataPack object which contains the data to render as an sql string * @return The sql prepared statement we are parsing */ public String selectDistinct(DataPack dp) { synchronized (syncSelectDistinct) { String sql = "SELECT DISTINCT " + dp.getSetClause() + " FROM " + dp.getTableName(); sql = getWhereString(dp, sql); return sql + ";"; } }
/** * Gets the where statement and conditions * * @param dataPack The DataPack object which contains the data to render as an sql string * @param sql The sql string we are parsing * @return The sql string concatenated with the where statement */ protected String getWhereString(DataPack dataPack, String sql) { synchronized (synchWhereString) { if (dataPack.getWhereClause() != null) { sql += " WHERE " + dataPack.getWhereClause(); } return sql; } }
/** * Creates a delete prepared statement * * @param dp The DataPack object which contains the data to render as an sql string * @return The sql string we are parsing */ public String delete(DataPack dp) { synchronized (syncDelete) { String s = "DELETE "; if (dp.getSetClause() != null) { s += dp.getSetClause(); } s += " FROM " + dp.getTableName(); s = getWhereString(dp, s); return s; } }
/** * Creates an insert prepared statement * * @param dp The DataPack object which contains the data to render as an sql string * @return The sql prepared statement we are parsing */ public synchronized String insert(DataPack dp) { synchronized (syncInsert) { String sql = "INSERT INTO " + dp.getTableName() + "(" + dp.getSetClause() + ")" + " VALUES(" + getQuestionMarks(dp.getDataCount()) + ")"; return getWhereString(dp, sql); } }
/** * Creates an update prepared statement * * @param dp The DataPack object which contains the data to render as an sql string * @return The sql prepared statement we are parsing */ public String update(DataPack dp) { synchronized (syncUpdate) { String statement = "UPDATE " + dp.getTableName() + " SET " + dp.getSetClause(); return getWhereString(dp, statement); } }