private String generateInsertSQL(SisSettings sisSettings) { return "insert into " + sisSettings.getStudentsTable() + " (" + sisSettings.studentIDFieldName() + ", " + sisSettings.freeFieldName() + ", " + sisSettings.reducedFieldName() + (isNotEmpty(sisSettings.activeFieldName()) ? "," + sisSettings.activeFieldName() : "") + (isNotEmpty(sisSettings.getFirstNameField()) ? "," + sisSettings.getFirstNameField() : "") + (isNotEmpty(sisSettings.getLastNameField()) ? "," + sisSettings.getLastNameField() : "") + ") values ( ?, ?, ?" + (isNotEmpty(sisSettings.activeFieldName()) ? ", ?" : "") + (isNotEmpty(sisSettings.getFirstNameField()) ? ", ?" : "") + (isNotEmpty(sisSettings.getLastNameField()) ? ", ?" : "") + ")"; }
private String generateSelectSQL(SisSettings sisSettings) { String activeField = isNotEmpty(sisSettings.activeFieldName()) ? ", " + sisSettings.activeFieldName() : ""; String nameFields = isNotEmpty(sisSettings.getLastNameField()) ? ", " + sisSettings.getFirstNameField() + ", " + sisSettings.getLastNameField() + " " : ""; return "select " + sisSettings.studentIDFieldName() + "," + sisSettings.freeFieldName() + ", " + sisSettings.reducedFieldName() + activeField + nameFields + " from " + sisSettings.getStudentsTable(); }
private void fillStatement(PreparedStatement insertStatement, ResultSet resultSet) throws SQLException { insertStatement.setString(1, resultSet.getString(1)); insertStatement.setString(2, resultSet.getString(2)); insertStatement.setString(3, resultSet.getString(3)); int resultSetCoulmnPosition = 4; if (isNotEmpty(remoteSis.activeFieldName())) { insertStatement.setString( resultSetCoulmnPosition, resultSet.getString(resultSetCoulmnPosition)); resultSetCoulmnPosition++; } if (isNotEmpty(remoteSis.getLastNameField())) { insertStatement.setString( resultSetCoulmnPosition, resultSet.getString(resultSetCoulmnPosition++)); insertStatement.setString( resultSetCoulmnPosition, resultSet.getString(resultSetCoulmnPosition)); } }