Package ai.dat.core.adapter
Class GenericSqlDatabaseAdapter
java.lang.Object
ai.dat.core.adapter.GenericSqlDatabaseAdapter
- All Implemented Interfaces:
DatabaseAdapter
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGenericSqlDatabaseAdapter(SemanticAdapter semanticAdapter, DataSource dataSource) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateTable(Connection conn, Table table) protected voiddropTableIfExists(Connection conn, String tableName) executeQuery(String sql) generateSql(@NonNull String semanticSql, @NonNull List<SemanticModel> semanticModels) getColumnMetadata(String sql) protected StringgetCreateTableSql(Table table) protected StringgetDropTableSqlIfExists(String tableName) protected StringgetInsertSql(Table table) protected abstract ObjecthandleSpecificTypes(Object value, int columnType) voidprotected voidinsertTable(Connection conn, Table table, List<List<String>> data) protected StringquoteIdentifier(String identifier) protected voidsetInsertParameters(PreparedStatement stmt, List<String> row, List<Column> columns) protected voidsetParameterValue(PreparedStatement stmt, int parameterIndex, String value, String dataType) protected Stringprotected abstract inttoColumnType(String dataType) 从数据类型映射到JDBC类型Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.dat.core.adapter.DatabaseAdapter
toAnsiSqlType
-
Field Details
-
semanticAdapter
-
dataSource
-
-
Constructor Details
-
GenericSqlDatabaseAdapter
-
-
Method Details
-
semanticAdapter
- Specified by:
semanticAdapterin interfaceDatabaseAdapter
-
generateSql
public String generateSql(@NonNull @NonNull String semanticSql, @NonNull @NonNull List<SemanticModel> semanticModels) - Specified by:
generateSqlin interfaceDatabaseAdapter
-
executeQuery
- Specified by:
executeQueryin interfaceDatabaseAdapter- Throws:
SQLException
-
handleSpecificTypes
-
getColumnMetadata
- Specified by:
getColumnMetadatain interfaceDatabaseAdapter- Throws:
SQLException
-
initTable
- Specified by:
initTablein interfaceDatabaseAdapter- Throws:
SQLException
-
dropTableIfExists
-
createTable
- Throws:
SQLException
-
getDropTableSqlIfExists
-
getCreateTableSql
-
stringDataType
-
insertTable
protected void insertTable(Connection conn, Table table, List<List<String>> data) throws SQLException - Throws:
SQLException
-
getInsertSql
-
setInsertParameters
protected void setInsertParameters(PreparedStatement stmt, List<String> row, List<Column> columns) throws SQLException - Throws:
SQLException
-
setParameterValue
protected void setParameterValue(PreparedStatement stmt, int parameterIndex, String value, String dataType) throws SQLException - Throws:
SQLException
-
toColumnType
从数据类型映射到JDBC类型- Parameters:
dataType-- Returns:
-
quoteIdentifier
-