Skip to content

Commit eb5a38f

Browse files
author
volker
committed
Add some metadata stubs for SQuirreL SQL Client. #1
1 parent d2eb1cf commit eb5a38f

File tree

4 files changed

+34
-38
lines changed

4 files changed

+34
-38
lines changed

src/com/inet/excel/ExcelConnection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ public void setAutoCommit( boolean autoCommit ) throws SQLException {
147147
*/
148148
@Override
149149
public boolean getAutoCommit() throws SQLException {
150-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
151-
return false;
150+
return true;
152151
}
153152

154153
/**

src/com/inet/excel/ExcelDatabaseMetaData.java

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public boolean nullsAreSortedAtEnd() throws SQLException {
219219
*/
220220
@Override
221221
public String getDatabaseProductVersion() throws SQLException {
222-
return null;
222+
return ExcelDriver.MAJOR_VERSION + "." + ExcelDriver.MINOR_VERSION;
223223
}
224224

225225
/**
@@ -347,53 +347,47 @@ public String getIdentifierQuoteString() throws SQLException {
347347
*/
348348
@Override
349349
public String getSQLKeywords() throws SQLException {
350-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
351-
return null;
350+
return "";
352351
}
353352

354353
/**
355354
* {@inheritDoc}
356355
*/
357356
@Override
358357
public String getNumericFunctions() throws SQLException {
359-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
360-
return null;
358+
return "";
361359
}
362360

363361
/**
364362
* {@inheritDoc}
365363
*/
366364
@Override
367365
public String getStringFunctions() throws SQLException {
368-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
369-
return null;
366+
return "";
370367
}
371368

372369
/**
373370
* {@inheritDoc}
374371
*/
375372
@Override
376373
public String getSystemFunctions() throws SQLException {
377-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
378-
return null;
374+
return "";
379375
}
380376

381377
/**
382378
* {@inheritDoc}
383379
*/
384380
@Override
385381
public String getTimeDateFunctions() throws SQLException {
386-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
387-
return null;
382+
return "";
388383
}
389384

390385
/**
391386
* {@inheritDoc}
392387
*/
393388
@Override
394389
public String getSearchStringEscape() throws SQLException {
395-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
396-
return null;
390+
return "";
397391
}
398392

399393
/**
@@ -634,17 +628,15 @@ public String getSchemaTerm() throws SQLException {
634628
*/
635629
@Override
636630
public String getProcedureTerm() throws SQLException {
637-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
638-
return null;
631+
return "sheet";
639632
}
640633

641634
/**
642635
* {@inheritDoc}
643636
*/
644637
@Override
645638
public String getCatalogTerm() throws SQLException {
646-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
647-
return null;
639+
return "file";
648640
}
649641

650642
/**
@@ -1181,26 +1173,26 @@ public ResultSet getProcedureColumns( String catalog, String schemaPattern, Stri
11811173
*/
11821174
@Override
11831175
public ResultSet getSchemas() throws SQLException {
1184-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
1185-
return null;
1176+
List<String> columnNames = Arrays.asList( "TABLE_SCHEM", "TABLE_CATALOG" );
1177+
return new ExcelDatabaseResultSet( columnNames, new ArrayList<>() );
11861178
}
11871179

11881180
/**
11891181
* {@inheritDoc}
11901182
*/
11911183
@Override
11921184
public ResultSet getCatalogs() throws SQLException {
1193-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
1194-
return null;
1185+
List<String> columnNames = Arrays.asList( "TABLE_CAT" );
1186+
return new ExcelDatabaseResultSet( columnNames, new ArrayList<>() );
11951187
}
11961188

11971189
/**
11981190
* {@inheritDoc}
11991191
*/
12001192
@Override
12011193
public ResultSet getTableTypes() throws SQLException {
1202-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
1203-
return null;
1194+
List<String> columnNames = Arrays.asList( "TABLE_TYPE" );
1195+
return new ExcelDatabaseResultSet( columnNames, new ArrayList<>() );
12041196
}
12051197

12061198
/**
@@ -1280,8 +1272,10 @@ public ResultSet getCrossReference( String parentCatalog, String parentSchema, S
12801272
*/
12811273
@Override
12821274
public ResultSet getTypeInfo() throws SQLException {
1283-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
1284-
return null;
1275+
List<String> columnNames = Arrays.asList( "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX", "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE", "SEARCHABLE", //
1276+
"UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE", "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE", "MAXIMUM_SCALE", //
1277+
"SQL_DATA_TYPE", "SQL_DATETIME_SUB", "NUM_PREC_RADIX" );
1278+
return new ExcelDatabaseResultSet( columnNames, new ArrayList<>() );
12851279
}
12861280

12871281
/**
@@ -1394,8 +1388,8 @@ public boolean supportsBatchUpdates() throws SQLException {
13941388
*/
13951389
@Override
13961390
public ResultSet getUDTs( String catalog, String schemaPattern, String typeNamePattern, int[] types ) throws SQLException {
1397-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
1398-
return null;
1391+
List<String> columnNames = Arrays.asList( "TYPE_CAT", "TYPE_SCHEM", "TYPE_NAME", "CLASS_NAME", "DATA_TYPE", "REMARKS", "BASE_TYPE" );
1392+
return new ExcelDatabaseResultSet( columnNames, new ArrayList<>() );
13991393
}
14001394

14011395
/**
@@ -1489,17 +1483,15 @@ public int getResultSetHoldability() throws SQLException {
14891483
*/
14901484
@Override
14911485
public int getDatabaseMajorVersion() throws SQLException {
1492-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
1493-
return 0;
1486+
return ExcelDriver.MAJOR_VERSION;
14941487
}
14951488

14961489
/**
14971490
* {@inheritDoc}
14981491
*/
14991492
@Override
15001493
public int getDatabaseMinorVersion() throws SQLException {
1501-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
1502-
return 0;
1494+
return ExcelDriver.MINOR_VERSION;
15031495
}
15041496

15051497
/**
@@ -1593,8 +1585,8 @@ public ResultSet getClientInfoProperties() throws SQLException {
15931585
*/
15941586
@Override
15951587
public ResultSet getFunctions( String catalog, String schemaPattern, String functionNamePattern ) throws SQLException {
1596-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
1597-
return null;
1588+
List<String> columnNames = Arrays.asList( "FUNCTION_CAT", "FUNCTION_SCHEM", "FUNCTION_NAME", "REMARKS", "FUNCTION_TYPE", "SPECIFIC_NAME" );
1589+
return new ExcelDatabaseResultSet( columnNames, new ArrayList<>() );
15981590
}
15991591

16001592
/**

src/com/inet/excel/ExcelDatabaseResultSet.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717

1818
import java.sql.ResultSetMetaData;
1919
import java.sql.SQLException;
20+
import java.util.Collections;
2021
import java.util.List;
2122

23+
import com.inet.excel.parser.ValueType;
24+
2225
/** Class for result set used to provide information about available procedures and procedure columns.
2326
*/
2427
public class ExcelDatabaseResultSet extends ExcelResultSet {
@@ -72,8 +75,9 @@ public void close() throws SQLException {
7275
*/
7376
@Override
7477
public ResultSetMetaData getMetaData() throws SQLException {
75-
ExcelDriver.throwExceptionAboutUnsupportedOperation();
76-
return null;
78+
List<String> columnNames = getColumnNames();
79+
List<ValueType> columnTypes = Collections.nCopies( columnNames.size(), ValueType.VARCHAR );
80+
return new ExcelSheetResultSetMetaData( "", "", columnNames, columnTypes );
7781
}
7882

7983
/**

src/com/inet/excel/ExcelResultSet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ public boolean isWrapperFor( Class<?> iface ) throws SQLException {
137137
*/
138138
@Override
139139
public String getString( int columnIndex ) throws SQLException {
140-
return getValue( columnIndex );
140+
Object value = getValue( columnIndex );
141+
return value != null ? value.toString() : null;
141142
}
142143

143144
/**

0 commit comments

Comments
 (0)