handle empty string in findColumn() method

This commit is contained in:
kimminseok
2025-10-09 10:46:27 +09:00
parent 76b57e5d0c
commit f9e95697c8
2 changed files with 4 additions and 5 deletions

View File

@@ -369,6 +369,10 @@ public final class JDBC4ResultSet implements ResultSet, ResultSetMetaData {
@Override
public int findColumn(String columnLabel) throws SQLException {
if (columnLabel == null || columnLabel.isEmpty()) {
throw new SQLException("column name not found");
}
final String[] columnNames = resultSet.getColumnNames();
for (int i = 0; i < columnNames.length; i++) {
if (columnNames[i].equals(columnLabel)) {

View File

@@ -674,11 +674,6 @@ class JDBC4ResultSetTest {
ResultSet resultSet = stmt.executeQuery("SELECT * FROM test_empty");
// Before calling next()
// Empty ResultSet should return false for isBeforeFirst()
assertFalse(resultSet.isBeforeFirst());
assertFalse(resultSet.isAfterLast());
// After calling next() on empty ResultSet
assertFalse(resultSet.next());
assertFalse(resultSet.isBeforeFirst());