You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.2 KiB

package hsfulda.de;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
public class FedResultSet implements FedResultSetInterface {
private FedStatement fedStatement;
private HashMap<Integer, ResultSet> resultSets = new HashMap<Integer, ResultSet>();
public FedResultSet(FedStatement fedStatement) {
this.fedStatement = fedStatement;
}
public FedStatement getStatement() {
return fedStatement;
}
public boolean next() throws FedException {
try {
for (Object i : resultSets.keySet()) {
if (resultSets.get(i).next())
return true;
}
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
return false;
}
public String getString(int columnIndex) throws FedException {
try {
for (Object i : resultSets.keySet()) {
if (!resultSets.get(i).isAfterLast())
return resultSets.get(i).getString(columnIndex);
}
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
return null;
}
public int getInt(int columnIndex) throws FedException {
try {
for (Object i : resultSets.keySet()) {
if (!resultSets.get(i).isAfterLast())
return resultSets.get(i).getInt(columnIndex);
}
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
return 0;
}
public void close() throws FedException {
try {
for (Object i : resultSets.keySet()) {
resultSets.get(i).close();
}
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
}
public int getColumnCount() throws FedException {
try {
return resultSets.get(0).getMetaData().getColumnCount();
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
}
public String getColumnName(int index) throws FedException {
try {
return resultSets.get(0).getMetaData().getColumnName(index);
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
}
public int getColumnType(int index) throws FedException {
try {
return resultSets.get(0).getMetaData().getColumnType(index);
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
}
public void setResultSet(int index, ResultSet resultSet) {
resultSets.put(index, resultSet);
}
}