@@ -196,13 +196,25 @@ private void populateColumns() {
196
196
}
197
197
198
198
@ Override
199
- DataType getCqlDataType (final int columnIndex ) {
200
- return this .currentRow .getColumnDefinitions ().getType (columnIndex - 1 );
199
+ DataType getCqlDataType (final int columnIndex ) throws SQLException {
200
+ if (this .currentRow != null && this .currentRow .getColumnDefinitions () != null ) {
201
+ return this .currentRow .getColumnDefinitions ().getType (columnIndex - 1 );
202
+ }
203
+ if (this .driverResultSet != null && this .driverResultSet .getColumnDefinitions () != null ) {
204
+ return this .driverResultSet .getColumnDefinitions ().getType (columnIndex - 1 );
205
+ }
206
+ throw new SQLException (UNABLE_TO_RETRIEVE_METADATA );
201
207
}
202
208
203
209
@ Override
204
- DataType getCqlDataType (final String columnLabel ) {
205
- return this .currentRow .getColumnDefinitions ().getType (columnLabel );
210
+ DataType getCqlDataType (final String columnLabel ) throws SQLException {
211
+ if (this .currentRow != null && this .currentRow .getColumnDefinitions () != null ) {
212
+ return this .currentRow .getColumnDefinitions ().getType (columnLabel );
213
+ }
214
+ if (this .driverResultSet != null && this .driverResultSet .getColumnDefinitions () != null ) {
215
+ return this .driverResultSet .getColumnDefinitions ().getType (columnLabel );
216
+ }
217
+ throw new SQLException (UNABLE_TO_RETRIEVE_METADATA );
206
218
}
207
219
208
220
@ Override
@@ -1071,7 +1083,7 @@ public String getColumnLabel(final int column) throws SQLException {
1071
1083
1072
1084
@ Override
1073
1085
public String getColumnName (final int column ) throws SQLException {
1074
- if (currentRow != null ) {
1086
+ if (currentRow != null && currentRow . getColumnDefinitions () != null ) {
1075
1087
return currentRow .getColumnDefinitions ().getName (column - 1 );
1076
1088
}
1077
1089
if (driverResultSet != null && driverResultSet .getColumnDefinitions () != null ) {
@@ -1085,7 +1097,7 @@ public int getColumnDisplaySize(final int column) {
1085
1097
try {
1086
1098
final AbstractJdbcType <?> jdbcEquivalentType ;
1087
1099
final ColumnDefinitions .Definition columnDefinition ;
1088
- if (currentRow != null ) {
1100
+ if (currentRow != null && currentRow . getColumnDefinitions () != null ) {
1089
1101
columnDefinition = currentRow .getColumnDefinitions ().asList ().get (column - 1 );
1090
1102
} else if (driverResultSet != null && driverResultSet .getColumnDefinitions () != null ) {
1091
1103
columnDefinition = driverResultSet .getColumnDefinitions ().asList ().get (column - 1 );
@@ -1105,7 +1117,7 @@ public int getColumnDisplaySize(final int column) {
1105
1117
}
1106
1118
1107
1119
@ Override
1108
- public int getColumnType (final int column ) {
1120
+ public int getColumnType (final int column ) throws SQLException {
1109
1121
final DataType type ;
1110
1122
if (currentRow != null ) {
1111
1123
type = getCqlDataType (column );
@@ -1118,7 +1130,7 @@ public int getColumnType(final int column) {
1118
1130
}
1119
1131
1120
1132
@ Override
1121
- public String getColumnTypeName (final int column ) {
1133
+ public String getColumnTypeName (final int column ) throws SQLException {
1122
1134
// Specification says "database specific type name"; for Cassandra this means the AbstractType.
1123
1135
final DataType type ;
1124
1136
if (currentRow != null ) {
@@ -1141,7 +1153,7 @@ public int getScale(final int column) {
1141
1153
try {
1142
1154
final AbstractJdbcType <?> jdbcEquivalentType ;
1143
1155
final ColumnDefinitions .Definition columnDefinition ;
1144
- if (currentRow != null ) {
1156
+ if (currentRow != null && currentRow . getColumnDefinitions () != null ) {
1145
1157
columnDefinition = currentRow .getColumnDefinitions ().asList ().get (column - 1 );
1146
1158
} else if (driverResultSet != null && driverResultSet .getColumnDefinitions () != null ) {
1147
1159
columnDefinition = driverResultSet .getColumnDefinitions ().asList ().get (column - 1 );
@@ -1171,7 +1183,7 @@ public String getSchemaName(final int column) throws SQLException {
1171
1183
@ Override
1172
1184
public String getTableName (final int column ) {
1173
1185
final String tableName ;
1174
- if (currentRow != null ) {
1186
+ if (currentRow != null && currentRow . getColumnDefinitions () != null ) {
1175
1187
tableName = currentRow .getColumnDefinitions ().getTable (column - 1 );
1176
1188
} else if (driverResultSet != null && driverResultSet .getColumnDefinitions () != null ) {
1177
1189
tableName = driverResultSet .getColumnDefinitions ().getTable (column - 1 );
@@ -1231,9 +1243,16 @@ public boolean isSearchable(final int column) throws SQLException {
1231
1243
return false ;
1232
1244
}
1233
1245
final String columnName = getColumnName (column );
1246
+ final String schemaName = getSchemaName (column );
1247
+ final String tableName = getTableName (column );
1248
+ // If the schema or table name is not defined, always returns false since we cannot determine if the column
1249
+ // is searchable in this context.
1250
+ if (StringUtils .isEmpty (schemaName ) || StringUtils .isEmpty (tableName )) {
1251
+ return false ;
1252
+ }
1234
1253
final AtomicBoolean searchable = new AtomicBoolean (false );
1235
- statement .connection .getSession ().getMetadata ().getKeyspace (getSchemaName ( column ) )
1236
- .flatMap (metadata -> metadata .getTable (getTableName ( column ) ))
1254
+ statement .connection .getSession ().getMetadata ().getKeyspace (schemaName )
1255
+ .flatMap (metadata -> metadata .getTable (tableName ))
1237
1256
.ifPresent (tableMetadata -> {
1238
1257
boolean result ;
1239
1258
// Check first if the column is a clustering column or in a partitioning key.
@@ -1250,7 +1269,7 @@ public boolean isSearchable(final int column) throws SQLException {
1250
1269
}
1251
1270
1252
1271
@ Override
1253
- public boolean isSigned (final int column ) {
1272
+ public boolean isSigned (final int column ) throws SQLException {
1254
1273
final DataType type ;
1255
1274
if (currentRow != null ) {
1256
1275
type = getCqlDataType (column );
0 commit comments