diff --git a/wayang-api/pom.xml b/wayang-api/pom.xml
index 9ac61fa54..ce1cd07b1 100644
--- a/wayang-api/pom.xml
+++ b/wayang-api/pom.xml
@@ -40,6 +40,7 @@
wayang-api-sql
wayang-api-json
wayang-api-utils
+ wayang-api-jdbc
diff --git a/wayang-api/wayang-api-jdbc/pom.xml b/wayang-api/wayang-api-jdbc/pom.xml
new file mode 100644
index 000000000..dded8c4d8
--- /dev/null
+++ b/wayang-api/wayang-api-jdbc/pom.xml
@@ -0,0 +1,112 @@
+
+
+
+ 4.0.0
+
+
+ wayang-api
+ org.apache.wayang
+ 1.1.2-SNAPSHOT
+
+
+ wayang-api-jdbc
+ Wayang API JDBC
+
+ JDBC driver for Apache Wayang that allows external tools to connect
+ to Wayang as if it were a relational database.
+
+
+
+
+
+ org.apache.wayang
+ wayang-api-sql
+ ${project.version}
+
+
+
+
+ org.apache.wayang
+ wayang-core
+ ${project.version}
+
+
+
+
+ org.apache.wayang
+ wayang-java
+ ${project.version}
+
+
+
+
+ org.apache.wayang
+ wayang-basic
+ ${project.version}
+
+
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ test
+
+
+
+
+ com.googlecode.json-simple
+ json-simple
+ 1.1.1
+ test
+
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
+
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED
+
+
+
+
+
\ No newline at end of file
diff --git a/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangConnection.java b/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangConnection.java
new file mode 100644
index 000000000..d4255e8c7
--- /dev/null
+++ b/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangConnection.java
@@ -0,0 +1,325 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.wayang.api.jdbc;
+
+import org.apache.wayang.api.sql.context.SqlContext;
+import org.apache.wayang.core.api.Configuration;
+
+import java.sql.*;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+
+public class WayangConnection implements Connection {
+
+ private final String url;
+ private final SqlContext sqlContext;
+ private boolean closed = false;
+ private final Properties properties;
+
+ public WayangConnection(final String url, final String configPath, final Properties properties) throws SQLException {
+ this.url = url;
+ this.properties = properties != null ? properties : new Properties();
+ try {
+ final Configuration configuration;
+ if (configPath != null && !configPath.isEmpty()) {
+ configuration = new Configuration(configPath);
+ } else {
+ configuration = new Configuration();
+ }
+ this.sqlContext = new SqlContext(configuration);
+ } catch (Exception e) {
+ throw new SQLException("Failed to create WayangConnection: " + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Package-private constructor for testing.
+ * Accepts a pre-built SqlContext directly, bypassing config file loading.
+ */
+ WayangConnection(final String url, final SqlContext sqlContext, final Properties properties) {
+ this.url = url;
+ this.properties = properties != null ? properties : new Properties();
+ this.sqlContext = sqlContext;
+ }
+
+ public SqlContext getSqlContext() {
+ return sqlContext;
+ }
+
+ @Override
+ public Statement createStatement() throws SQLException {
+ checkClosed();
+ return new WayangStatement(this);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(final String sql) throws SQLException {
+ checkClosed();
+ return new WayangPreparedStatement(this, sql);
+ }
+
+ @Override
+ public void close() throws SQLException {
+ this.closed = true;
+ }
+
+ @Override
+ public boolean isClosed() throws SQLException {
+ return closed;
+ }
+
+ @Override
+ public boolean isValid(final int timeout) throws SQLException {
+ return !closed;
+ }
+
+ @Override
+ public DatabaseMetaData getMetaData() throws SQLException {
+ checkClosed();
+ return new WayangDatabaseMetaData(this);
+ }
+
+ @Override
+ public String getCatalog() throws SQLException {
+ return "wayang";
+ }
+
+ @Override
+ public void setCatalog(final String catalog) throws SQLException {}
+
+ @Override
+ public int getTransactionIsolation() throws SQLException {
+ return Connection.TRANSACTION_NONE;
+ }
+
+ @Override
+ public void setTransactionIsolation(final int level) throws SQLException {}
+
+ @Override
+ public boolean getAutoCommit() throws SQLException {
+ return true;
+ }
+
+ @Override
+ public void setAutoCommit(final boolean autoCommit) throws SQLException {}
+
+ @Override
+ public void commit() throws SQLException {}
+
+ @Override
+ public void rollback() throws SQLException {
+ throw new SQLFeatureNotSupportedException("Wayang does not support transactions");
+ }
+
+ @Override
+ public void rollback(final Savepoint savepoint) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Wayang does not support transactions");
+ }
+
+ @Override
+ public Statement createStatement(final int resultSetType, final int resultSetConcurrency) throws SQLException {
+ return createStatement();
+ }
+
+ @Override
+ public Statement createStatement(final int resultSetType, final int resultSetConcurrency,
+ final int resultSetHoldability) throws SQLException {
+ return createStatement();
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(final String sql, final int resultSetType,
+ final int resultSetConcurrency) throws SQLException {
+ return prepareStatement(sql);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(final String sql, final int resultSetType,
+ final int resultSetConcurrency, final int resultSetHoldability) throws SQLException {
+ return prepareStatement(sql);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(final String sql, final int autoGeneratedKeys) throws SQLException {
+ return prepareStatement(sql);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(final String sql, final int[] columnIndexes) throws SQLException {
+ return prepareStatement(sql);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(final String sql, final String[] columnNames) throws SQLException {
+ return prepareStatement(sql);
+ }
+
+ @Override
+ public CallableStatement prepareCall(final String sql) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Wayang does not support stored procedures");
+ }
+
+ @Override
+ public CallableStatement prepareCall(final String sql, final int resultSetType,
+ final int resultSetConcurrency) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Wayang does not support stored procedures");
+ }
+
+ @Override
+ public CallableStatement prepareCall(final String sql, final int resultSetType,
+ final int resultSetConcurrency, final int resultSetHoldability) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Wayang does not support stored procedures");
+ }
+
+ @Override
+ public String nativeSQL(final String sql) throws SQLException {
+ return sql;
+ }
+
+ @Override
+ public SQLWarning getWarnings() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public void clearWarnings() throws SQLException {}
+
+ @Override
+ public Map> getTypeMap() throws SQLException {
+ throw new SQLFeatureNotSupportedException("getTypeMap not supported");
+ }
+
+ @Override
+ public void setTypeMap(final Map> map) throws SQLException {
+ throw new SQLFeatureNotSupportedException("setTypeMap not supported");
+ }
+
+ @Override
+ public int getHoldability() throws SQLException {
+ return ResultSet.CLOSE_CURSORS_AT_COMMIT;
+ }
+
+ @Override
+ public void setHoldability(final int holdability) throws SQLException {}
+
+ @Override
+ public Savepoint setSavepoint() throws SQLException {
+ throw new SQLFeatureNotSupportedException("Wayang does not support savepoints");
+ }
+
+ @Override
+ public Savepoint setSavepoint(final String name) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Wayang does not support savepoints");
+ }
+
+ @Override
+ public void releaseSavepoint(final Savepoint savepoint) throws SQLException {
+ throw new SQLFeatureNotSupportedException("Wayang does not support savepoints");
+ }
+
+ @Override
+ public boolean isReadOnly() throws SQLException {
+ return true;
+ }
+
+ @Override
+ public void setReadOnly(final boolean readOnly) throws SQLException {}
+
+ @Override
+ public String getSchema() throws SQLException {
+ return "wayang";
+ }
+
+ @Override
+ public void setSchema(final String schema) throws SQLException {}
+
+ @Override
+ public void abort(final Executor executor) throws SQLException {
+ close();
+ }
+
+ @Override
+ public void setNetworkTimeout(final Executor executor, final int milliseconds) throws SQLException {}
+
+ @Override
+ public int getNetworkTimeout() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public Clob createClob() throws SQLException {
+ throw new SQLFeatureNotSupportedException("createClob not supported");
+ }
+
+ @Override
+ public Blob createBlob() throws SQLException {
+ throw new SQLFeatureNotSupportedException("createBlob not supported");
+ }
+
+ @Override
+ public NClob createNClob() throws SQLException {
+ throw new SQLFeatureNotSupportedException("createNClob not supported");
+ }
+
+ @Override
+ public SQLXML createSQLXML() throws SQLException {
+ throw new SQLFeatureNotSupportedException("createSQLXML not supported");
+ }
+
+ @Override
+ public java.sql.Array createArrayOf(final String typeName, final Object[] elements) throws SQLException {
+ throw new SQLFeatureNotSupportedException("createArrayOf not supported");
+ }
+
+ @Override
+ public Struct createStruct(final String typeName, final Object[] attributes) throws SQLException {
+ throw new SQLFeatureNotSupportedException("createStruct not supported");
+ }
+
+ @Override
+ public void setClientInfo(final String name, final String value) throws SQLClientInfoException {}
+
+ @Override
+ public void setClientInfo(final Properties properties) throws SQLClientInfoException {}
+
+ @Override
+ public String getClientInfo(final String name) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public Properties getClientInfo() throws SQLException {
+ return new Properties();
+ }
+
+ @Override
+ public T unwrap(final Class iface) throws SQLException {
+ if (iface.isInstance(this)) return iface.cast(this);
+ throw new SQLException("Cannot unwrap to " + iface.getName());
+ }
+
+ @Override
+ public boolean isWrapperFor(final Class> iface) throws SQLException {
+ return iface.isInstance(this);
+ }
+
+ private void checkClosed() throws SQLException {
+ if (closed) throw new SQLException("Connection is closed");
+ }
+}
\ No newline at end of file
diff --git a/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangDatabaseMetaData.java b/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangDatabaseMetaData.java
new file mode 100644
index 000000000..1ea45c99b
--- /dev/null
+++ b/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangDatabaseMetaData.java
@@ -0,0 +1,544 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.wayang.api.jdbc;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * JDBC DatabaseMetaData implementation for Apache Wayang.
+ *
+ * Describes the Wayang "database" to external tools:
+ * - Product name and version
+ * - Supported SQL features
+ * - Available schemas and tables
+ *
+ * Tools like DBeaver call this immediately after connecting
+ * to understand what they are talking to.
+ */
+public class WayangDatabaseMetaData implements DatabaseMetaData {
+
+ private final WayangConnection connection;
+
+ public WayangDatabaseMetaData(final WayangConnection connection) {
+ this.connection = connection;
+ }
+
+ // -------------------------------------------------------------------------
+ // Product identity — what is this database?
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String getDatabaseProductName() throws SQLException {
+ return "Apache Wayang";
+ }
+
+ @Override
+ public String getDatabaseProductVersion() throws SQLException {
+ return "1.1.2-SNAPSHOT";
+ }
+
+ @Override
+ public String getDriverName() throws SQLException {
+ return "Wayang JDBC Driver";
+ }
+
+ @Override
+ public String getDriverVersion() throws SQLException {
+ return WayangDriver.MAJOR_VERSION + "." + WayangDriver.MINOR_VERSION;
+ }
+
+ @Override
+ public int getDriverMajorVersion() {
+ return WayangDriver.MAJOR_VERSION;
+ }
+
+ @Override
+ public int getDriverMinorVersion() {
+ return WayangDriver.MINOR_VERSION;
+ }
+
+ @Override
+ public int getDatabaseMajorVersion() throws SQLException {
+ return 1;
+ }
+
+ @Override
+ public int getDatabaseMinorVersion() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getJDBCMajorVersion() throws SQLException {
+ return 4;
+ }
+
+ @Override
+ public int getJDBCMinorVersion() throws SQLException {
+ return 2;
+ }
+
+ // -------------------------------------------------------------------------
+ // Connection info
+ // -------------------------------------------------------------------------
+
+ @Override
+ public Connection getConnection() throws SQLException {
+ return connection;
+ }
+
+ @Override
+ public String getURL() throws SQLException {
+ return connection.getCatalog();
+ }
+
+ @Override
+ public String getUserName() throws SQLException {
+ return "wayang";
+ }
+
+ // -------------------------------------------------------------------------
+ // SQL syntax support
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String getSQLKeywords() throws SQLException {
+ return "";
+ }
+
+ @Override
+ public String getNumericFunctions() throws SQLException {
+ return "ABS,CEIL,FLOOR,ROUND,MOD";
+ }
+
+ @Override
+ public String getStringFunctions() throws SQLException {
+ return "CONCAT,LOWER,UPPER,TRIM,SUBSTRING,LENGTH";
+ }
+
+ @Override
+ public String getSystemFunctions() throws SQLException {
+ return "DATABASE,USER,IFNULL";
+ }
+
+ @Override
+ public String getTimeDateFunctions() throws SQLException {
+ return "CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP";
+ }
+
+ @Override
+ public String getSearchStringEscape() throws SQLException {
+ return "\\";
+ }
+
+ @Override
+ public String getExtraNameCharacters() throws SQLException {
+ return "";
+ }
+
+ @Override
+ public String getIdentifierQuoteString() throws SQLException {
+ return "\"";
+ }
+
+ @Override
+ public String getCatalogSeparator() throws SQLException {
+ return ".";
+ }
+
+ @Override
+ public String getCatalogTerm() throws SQLException {
+ return "catalog";
+ }
+
+ @Override
+ public String getSchemaTerm() throws SQLException {
+ return "schema";
+ }
+
+ @Override
+ public String getProcedureTerm() throws SQLException {
+ return "procedure";
+ }
+
+ // -------------------------------------------------------------------------
+ // Feature support flags
+ // -------------------------------------------------------------------------
+
+ @Override public boolean allProceduresAreCallable() throws SQLException { return false; }
+ @Override public boolean allTablesAreSelectable() throws SQLException { return true; }
+ @Override public boolean isReadOnly() throws SQLException { return true; }
+ @Override public boolean nullsAreSortedHigh() throws SQLException { return false; }
+ @Override public boolean nullsAreSortedLow() throws SQLException { return true; }
+ @Override public boolean nullsAreSortedAtStart() throws SQLException { return false; }
+ @Override public boolean nullsAreSortedAtEnd() throws SQLException { return false; }
+ @Override public boolean usesLocalFiles() throws SQLException { return false; }
+ @Override public boolean usesLocalFilePerTable() throws SQLException { return false; }
+ @Override public boolean supportsMixedCaseIdentifiers() throws SQLException { return false; }
+ @Override public boolean storesUpperCaseIdentifiers() throws SQLException { return false; }
+ @Override public boolean storesLowerCaseIdentifiers() throws SQLException { return true; }
+ @Override public boolean storesMixedCaseIdentifiers() throws SQLException { return false; }
+ @Override public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { return true; }
+ @Override public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { return false; }
+ @Override public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { return false; }
+ @Override public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { return true; }
+ @Override public boolean supportsAlterTableWithAddColumn() throws SQLException { return false; }
+ @Override public boolean supportsAlterTableWithDropColumn() throws SQLException { return false; }
+ @Override public boolean supportsColumnAliasing() throws SQLException { return true; }
+ @Override public boolean nullPlusNonNullIsNull() throws SQLException { return true; }
+ @Override public boolean supportsConvert() throws SQLException { return false; }
+ @Override public boolean supportsConvert(int fromType, int toType) throws SQLException { return false; }
+ @Override public boolean supportsTableCorrelationNames() throws SQLException { return true; }
+ @Override public boolean supportsDifferentTableCorrelationNames() throws SQLException { return false; }
+ @Override public boolean supportsExpressionsInOrderBy() throws SQLException { return true; }
+ @Override public boolean supportsOrderByUnrelated() throws SQLException { return false; }
+ @Override public boolean supportsGroupBy() throws SQLException { return true; }
+ @Override public boolean supportsGroupByUnrelated() throws SQLException { return false; }
+ @Override public boolean supportsGroupByBeyondSelect() throws SQLException { return false; }
+ @Override public boolean supportsLikeEscapeClause() throws SQLException { return false; }
+ @Override public boolean supportsMultipleResultSets() throws SQLException { return false; }
+ @Override public boolean supportsMultipleTransactions() throws SQLException { return false; }
+ @Override public boolean supportsNonNullableColumns() throws SQLException { return false; }
+ @Override public boolean supportsMinimumSQLGrammar() throws SQLException { return true; }
+ @Override public boolean supportsCoreSQLGrammar() throws SQLException { return false; }
+ @Override public boolean supportsExtendedSQLGrammar() throws SQLException { return false; }
+ @Override public boolean supportsANSI92EntryLevelSQL() throws SQLException { return true; }
+ @Override public boolean supportsANSI92IntermediateSQL() throws SQLException { return false; }
+ @Override public boolean supportsANSI92FullSQL() throws SQLException { return false; }
+ @Override public boolean supportsIntegrityEnhancementFacility() throws SQLException { return false; }
+ @Override public boolean supportsOuterJoins() throws SQLException { return true; }
+ @Override public boolean supportsFullOuterJoins() throws SQLException { return false; }
+ @Override public boolean supportsLimitedOuterJoins() throws SQLException { return true; }
+ @Override public boolean isCatalogAtStart() throws SQLException { return true; }
+ @Override public boolean supportsSchemasInDataManipulation() throws SQLException { return true; }
+ @Override public boolean supportsSchemasInProcedureCalls() throws SQLException { return false; }
+ @Override public boolean supportsSchemasInTableDefinitions() throws SQLException { return false; }
+ @Override public boolean supportsSchemasInIndexDefinitions() throws SQLException { return false; }
+ @Override public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { return false; }
+ @Override public boolean supportsCatalogsInDataManipulation() throws SQLException { return false; }
+ @Override public boolean supportsCatalogsInProcedureCalls() throws SQLException { return false; }
+ @Override public boolean supportsCatalogsInTableDefinitions() throws SQLException { return false; }
+ @Override public boolean supportsCatalogsInIndexDefinitions() throws SQLException { return false; }
+ @Override public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { return false; }
+ @Override public boolean supportsPositionedDelete() throws SQLException { return false; }
+ @Override public boolean supportsPositionedUpdate() throws SQLException { return false; }
+ @Override public boolean supportsSelectForUpdate() throws SQLException { return false; }
+ @Override public boolean supportsStoredProcedures() throws SQLException { return false; }
+ @Override public boolean supportsSubqueriesInComparisons() throws SQLException { return true; }
+ @Override public boolean supportsSubqueriesInExists() throws SQLException { return true; }
+ @Override public boolean supportsSubqueriesInIns() throws SQLException { return true; }
+ @Override public boolean supportsSubqueriesInQuantifieds() throws SQLException { return false; }
+ @Override public boolean supportsCorrelatedSubqueries() throws SQLException { return false; }
+ @Override public boolean supportsUnion() throws SQLException { return false; }
+ @Override public boolean supportsUnionAll() throws SQLException { return false; }
+ @Override public boolean supportsOpenCursorsAcrossCommit() throws SQLException { return false; }
+ @Override public boolean supportsOpenCursorsAcrossRollback() throws SQLException { return false; }
+ @Override public boolean supportsOpenStatementsAcrossCommit() throws SQLException { return false; }
+ @Override public boolean supportsOpenStatementsAcrossRollback() throws SQLException { return false; }
+ @Override public boolean supportsTransactions() throws SQLException { return false; }
+ @Override
+ public boolean supportsSavepoints() throws SQLException {
+ return false;
+ }
+ @Override public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { return false; }
+ @Override public boolean supportsDataManipulationTransactionsOnly() throws SQLException { return false; }
+ @Override public boolean dataDefinitionCausesTransactionCommit() throws SQLException { return false; }
+ @Override public boolean dataDefinitionIgnoredInTransactions() throws SQLException { return false; }
+ @Override public boolean supportsBatchUpdates() throws SQLException { return false; }
+ @Override public boolean supportsNamedParameters() throws SQLException { return false; }
+ @Override public boolean supportsMultipleOpenResults() throws SQLException { return false; }
+ @Override public boolean supportsGetGeneratedKeys() throws SQLException { return false; }
+ @Override public boolean supportsResultSetType(int type) throws SQLException { return type == ResultSet.TYPE_FORWARD_ONLY; }
+ @Override public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException { return concurrency == ResultSet.CONCUR_READ_ONLY; }
+ @Override public boolean ownUpdatesAreVisible(int type) throws SQLException { return false; }
+ @Override public boolean ownDeletesAreVisible(int type) throws SQLException { return false; }
+ @Override public boolean ownInsertsAreVisible(int type) throws SQLException { return false; }
+ @Override public boolean othersUpdatesAreVisible(int type) throws SQLException { return false; }
+ @Override public boolean othersDeletesAreVisible(int type) throws SQLException { return false; }
+ @Override public boolean othersInsertsAreVisible(int type) throws SQLException { return false; }
+ @Override public boolean updatesAreDetected(int type) throws SQLException { return false; }
+ @Override public boolean deletesAreDetected(int type) throws SQLException { return false; }
+ @Override public boolean insertsAreDetected(int type) throws SQLException { return false; }
+ @Override public boolean locatorsUpdateCopy() throws SQLException { return false; }
+ @Override public boolean supportsStatementPooling() throws SQLException { return false; }
+ @Override public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { return false; }
+ @Override public boolean autoCommitFailureClosesAllResultSets() throws SQLException { return false; }
+ @Override public boolean generatedKeyAlwaysReturned() throws SQLException { return false; }
+
+ // -------------------------------------------------------------------------
+ // Limits
+ // -------------------------------------------------------------------------
+
+ @Override public int getMaxBinaryLiteralLength() throws SQLException { return 0; }
+ @Override public int getMaxCharLiteralLength() throws SQLException { return 0; }
+ @Override public int getMaxColumnNameLength() throws SQLException { return 0; }
+ @Override public int getMaxColumnsInGroupBy() throws SQLException { return 0; }
+ @Override public int getMaxColumnsInIndex() throws SQLException { return 0; }
+ @Override public int getMaxColumnsInOrderBy() throws SQLException { return 0; }
+ @Override public int getMaxColumnsInSelect() throws SQLException { return 0; }
+ @Override public int getMaxColumnsInTable() throws SQLException { return 0; }
+ @Override public int getMaxConnections() throws SQLException { return 0; }
+ @Override public int getMaxCursorNameLength() throws SQLException { return 0; }
+ @Override public int getMaxIndexLength() throws SQLException { return 0; }
+ @Override public int getMaxSchemaNameLength() throws SQLException { return 0; }
+ @Override public int getMaxProcedureNameLength() throws SQLException { return 0; }
+ @Override public int getMaxCatalogNameLength() throws SQLException { return 0; }
+ @Override public int getMaxRowSize() throws SQLException { return 0; }
+ @Override public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { return false; }
+ @Override public int getMaxStatementLength() throws SQLException { return 0; }
+ @Override public int getMaxStatements() throws SQLException { return 0; }
+ @Override public int getMaxTableNameLength() throws SQLException { return 0; }
+ @Override public int getMaxTablesInSelect() throws SQLException { return 0; }
+ @Override public int getMaxUserNameLength() throws SQLException { return 0; }
+
+ // -------------------------------------------------------------------------
+ // Transactions
+ // -------------------------------------------------------------------------
+
+ @Override
+ public boolean supportsTransactionIsolationLevel(final int level) throws SQLException {
+ return level == Connection.TRANSACTION_NONE;
+ }
+
+ @Override
+ public int getDefaultTransactionIsolation() throws SQLException {
+ return Connection.TRANSACTION_NONE;
+ }
+
+ // -------------------------------------------------------------------------
+ // Schema / Table / Column metadata ResultSets (return empty sets)
+ // -------------------------------------------------------------------------
+
+ @Override
+ public ResultSet getSchemas() throws SQLException {
+ final java.util.List rows = new ArrayList<>();
+ final java.util.List colNames = java.util.Arrays.asList("TABLE_SCHEM", "TABLE_CATALOG");
+ rows.add(new org.apache.wayang.basic.data.Record(new Object[]{"wayang", "wayang"}));
+ final WayangResultSet rs = new WayangResultSet(rows, "getSchemas");
+ rs.overrideColumnNames(colNames);
+ return rs;
+ }
+
+ @Override
+ public ResultSet getSchemas(final String catalog, final String schemaPattern) throws SQLException {
+ return getSchemas();
+ }
+
+ @Override
+ public ResultSet getCatalogs() throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getTables(final String catalog, final String schemaPattern,
+ final String tableNamePattern, final String[] types) throws SQLException {
+ final java.util.List rows = new ArrayList<>();
+ final java.util.List colNames = java.util.Arrays.asList(
+ "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "TABLE_TYPE",
+ "REMARKS", "TYPE_CAT", "TYPE_SCHEM", "TYPE_NAME",
+ "SELF_REFERENCING_COL_NAME", "REF_GENERATION");
+ rows.add(new org.apache.wayang.basic.data.Record(new Object[]{
+ "wayang", "wayang", "wayang_table", "TABLE",
+ "Apache Wayang virtual table", null, null, null, null, null}));
+ final WayangResultSet rs = new WayangResultSet(rows, "getTables");
+ rs.overrideColumnNames(colNames);
+ return rs;
+ }
+
+ @Override
+ public ResultSet getColumns(final String catalog, final String schemaPattern,
+ final String tableNamePattern, final String columnNamePattern) throws SQLException {
+ final java.util.List rows = new ArrayList<>();
+ final java.util.List colNames = java.util.Arrays.asList(
+ "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME",
+ "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH",
+ "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS",
+ "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB",
+ "CHAR_OCTET_LENGTH", "ORDINAL_POSITION", "IS_NULLABLE",
+ "SCOPE_CATALOG", "SCOPE_SCHEMA", "SCOPE_TABLE",
+ "SOURCE_DATA_TYPE", "IS_AUTOINCREMENT", "IS_GENERATEDCOLUMN");
+ final WayangResultSet rs = new WayangResultSet(rows, "getColumns");
+ rs.overrideColumnNames(colNames);
+ return rs;
+ }
+
+ @Override
+ public ResultSet getPrimaryKeys(final String catalog, final String schema,
+ final String table) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getTableTypes() throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getProcedures(final String catalog, final String schemaPattern,
+ final String procedureNamePattern) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getProcedureColumns(final String catalog, final String schemaPattern,
+ final String procedureNamePattern, final String columnNamePattern) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getColumnPrivileges(final String catalog, final String schema,
+ final String table, final String columnNamePattern) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getTablePrivileges(final String catalog, final String schemaPattern,
+ final String tableNamePattern) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getBestRowIdentifier(final String catalog, final String schema,
+ final String table, final int scope, final boolean nullable) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getVersionColumns(final String catalog, final String schema,
+ final String table) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getImportedKeys(final String catalog, final String schema,
+ final String table) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getExportedKeys(final String catalog, final String schema,
+ final String table) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getCrossReference(final String parentCatalog, final String parentSchema,
+ final String parentTable, final String foreignCatalog, final String foreignSchema,
+ final String foreignTable) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getTypeInfo() throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getIndexInfo(final String catalog, final String schema, final String table,
+ final boolean unique, final boolean approximate) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getUDTs(final String catalog, final String schemaPattern,
+ final String typeNamePattern, final int[] types) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getSuperTypes(final String catalog, final String schemaPattern,
+ final String typeNamePattern) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getSuperTables(final String catalog, final String schemaPattern,
+ final String tableNamePattern) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getAttributes(final String catalog, final String schemaPattern,
+ final String typeNamePattern, final String attributeNamePattern) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getClientInfoProperties() throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getFunctions(final String catalog, final String schemaPattern,
+ final String functionNamePattern) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getFunctionColumns(final String catalog, final String schemaPattern,
+ final String functionNamePattern, final String columnNamePattern) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public ResultSet getPseudoColumns(final String catalog, final String schemaPattern,
+ final String tableNamePattern, final String columnNamePattern) throws SQLException {
+ return emptyResultSet();
+ }
+
+ @Override
+ public RowIdLifetime getRowIdLifetime() throws SQLException {
+ return RowIdLifetime.ROWID_UNSUPPORTED;
+ }
+
+ @Override
+ public int getSQLStateType() throws SQLException {
+ return sqlStateSQL;
+ }
+
+ @Override
+ public int getResultSetHoldability() throws SQLException {
+ return ResultSet.CLOSE_CURSORS_AT_COMMIT;
+ }
+
+ @Override
+ public boolean supportsResultSetHoldability(final int holdability) throws SQLException {
+ return holdability == ResultSet.CLOSE_CURSORS_AT_COMMIT;
+ }
+
+ // -------------------------------------------------------------------------
+ // Unwrap
+ // -------------------------------------------------------------------------
+
+ @Override
+ public T unwrap(final Class iface) throws SQLException {
+ if (iface.isInstance(this)) return iface.cast(this);
+ throw new SQLException("Cannot unwrap to " + iface.getName());
+ }
+
+ @Override
+ public boolean isWrapperFor(final Class> iface) throws SQLException {
+ return iface.isInstance(this);
+ }
+
+ /** Returns an empty ResultSet for metadata queries that have no data yet */
+ private ResultSet emptyResultSet() throws SQLException {
+ return new WayangResultSet(new ArrayList<>(), "");
+ }
+}
\ No newline at end of file
diff --git a/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangDriver.java b/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangDriver.java
new file mode 100644
index 000000000..3130140c5
--- /dev/null
+++ b/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangDriver.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.wayang.api.jdbc;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+/**
+ * JDBC Driver for Apache Wayang.
+ *
+ * Allows external tools to connect to Wayang using standard JDBC.
+ *
+ * Connection URL format:
+ * jdbc:wayang:
+ *
+ * Example:
+ * jdbc:wayang:/path/to/wayang.properties
+ *
+ * Usage:
+ * Connection conn = DriverManager.getConnection("jdbc:wayang:/path/to/config.properties");
+ * Statement stmt = conn.createStatement();
+ * ResultSet rs = stmt.executeQuery("SELECT * FROM myTable");
+ */
+public class WayangDriver implements Driver {
+
+ /** The prefix all Wayang JDBC URLs must start with */
+ public static final String URL_PREFIX = "jdbc:wayang:";
+
+ /** JDBC driver version */
+ public static final int MAJOR_VERSION = 1;
+ public static final int MINOR_VERSION = 0;
+
+ // Auto-register this driver with the DriverManager when the class is loaded
+ static {
+ try {
+ DriverManager.registerDriver(new WayangDriver());
+ } catch (SQLException e) {
+ throw new RuntimeException("Failed to register WayangDriver", e);
+ }
+ }
+
+ /**
+ * Attempts to connect to Wayang using the given URL.
+ *
+ * @param url Must start with "jdbc:wayang:"
+ * @param info Optional properties (unused for now)
+ * @return a WayangConnection, or null if the URL is not for this driver
+ */
+ @Override
+ public Connection connect(final String url, final Properties info) throws SQLException {
+ if (!acceptsURL(url)) {
+ // Returning null tells DriverManager this driver can't handle this URL
+ return null;
+ }
+
+ // Extract the config path from the URL
+ // e.g. "jdbc:wayang:/path/to/config.properties" -> "/path/to/config.properties"
+ final String configPath = url.substring(URL_PREFIX.length());
+
+ return new WayangConnection(url, configPath, info);
+ }
+
+ /**
+ * Returns true if this driver can handle the given URL.
+ * Only accepts URLs starting with "jdbc:wayang:"
+ */
+ @Override
+ public boolean acceptsURL(final String url) throws SQLException {
+ return url != null && url.startsWith(URL_PREFIX);
+ }
+
+ @Override
+ public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) throws SQLException {
+ return new DriverPropertyInfo[0];
+ }
+
+ @Override
+ public int getMajorVersion() {
+ return MAJOR_VERSION;
+ }
+
+ @Override
+ public int getMinorVersion() {
+ return MINOR_VERSION;
+ }
+
+ /**
+ * JDBC-compliant means it fully implements the JDBC spec.
+ * We return false since this is an incomplete/custom implementation.
+ */
+ @Override
+ public boolean jdbcCompliant() {
+ return false;
+ }
+
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ throw new SQLFeatureNotSupportedException("WayangDriver does not use java.util.logging");
+ }
+}
\ No newline at end of file
diff --git a/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangPreparedStatement.java b/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangPreparedStatement.java
new file mode 100644
index 000000000..68c389019
--- /dev/null
+++ b/wayang-api/wayang-api-jdbc/src/main/java/org/apache/wayang/api/jdbc/WayangPreparedStatement.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.wayang.api.jdbc;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+public class WayangPreparedStatement extends WayangStatement implements PreparedStatement {
+
+ private final String sqlTemplate;
+ private final List