lowka commented on code in PR #6654:
URL: https://github.com/apache/ignite-3/pull/6654#discussion_r2387732302


##########
modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection2.java:
##########
@@ -0,0 +1,696 @@
+/*
+ * 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.ignite.internal.jdbc2;
+
+import static java.sql.ResultSet.CONCUR_READ_ONLY;
+import static java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT;
+import static java.sql.ResultSet.TYPE_FORWARD_ONLY;
+import static 
org.apache.ignite.internal.jdbc.proto.SqlStateCode.CONNECTION_CLOSED;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.ShardingKey;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.internal.jdbc.ConnectionProperties;
+import org.apache.ignite.internal.jdbc.JdbcDatabaseMetadata;
+import org.apache.ignite.internal.jdbc.proto.JdbcQueryEventHandler;
+import org.apache.ignite.internal.jdbc.proto.SqlStateCode;
+import org.apache.ignite.internal.lang.IgniteExceptionMapperUtil;
+import org.apache.ignite.internal.sql.SqlCommon;
+import org.apache.ignite.lang.util.IgniteNameUtils;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * {@link Connection} implementation backed by the thin client.
+ */
+public class JdbcConnection2 implements Connection {
+
+    private final IgniteClient client;
+
+    private final JdbcDatabaseMetadata metadata;
+
+    private String schemaName;
+
+    private volatile boolean closed;
+
+    private int txIsolation;
+
+    private boolean autoCommit;
+
+    private boolean readOnly;
+
+    private int networkTimeoutMillis;
+
+    /**
+     * Creates new connection.
+     *
+     * @param client Client.
+     * @param eventHandler Event handler.
+     * @param props Connection properties.
+     */
+    public JdbcConnection2(
+            IgniteClient client,
+            JdbcQueryEventHandler eventHandler,
+            ConnectionProperties props
+    ) throws SQLException {
+        autoCommit = true;
+
+        networkTimeoutMillis = props.getConnectionTimeout();
+        txIsolation = TRANSACTION_NONE;
+        schemaName = readSchemaName(props.getSchema());
+
+        this.client = client;
+        //noinspection ThisEscapedInObjectConstruction
+        metadata = new JdbcDatabaseMetadata(this, eventHandler, 
props.getUrl(), props.getUsername());
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Statement createStatement() throws SQLException {
+        return createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Statement createStatement(int resSetType, int resSetConcurrency) 
throws SQLException {
+        return createStatement(resSetType, resSetConcurrency, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Statement createStatement(int resSetType, int resSetConcurrency,
+            int resSetHoldability) throws SQLException {
+        ensureNotClosed();
+
+        checkCursorOptions(resSetType, resSetConcurrency, resSetHoldability);
+
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql) throws SQLException {
+        return prepareStatement(sql, TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int 
autoGeneratedKeys) throws SQLException {
+        ensureNotClosed();
+
+        throw new SQLFeatureNotSupportedException("Auto generated keys are not 
supported.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resSetType,
+            int resSetConcurrency) throws SQLException {
+        return prepareStatement(sql, resSetType, resSetConcurrency, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resSetType, int 
resSetConcurrency,
+            int resSetHoldability) throws SQLException {
+        ensureNotClosed();
+
+        checkCursorOptions(resSetType, resSetConcurrency, resSetHoldability);
+
+        if (sql == null) {
+            throw new SQLException("SQL string cannot be null.");
+        }
+
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int[] colIndexes) 
throws SQLException {
+        ensureNotClosed();
+
+        throw new SQLFeatureNotSupportedException("Auto generated keys are not 
supported.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, String[] colNames) 
throws SQLException {
+        ensureNotClosed();
+
+        throw new SQLFeatureNotSupportedException("Auto generated keys are not 
supported.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String nativeSQL(String sql) throws SQLException {
+        ensureNotClosed();
+
+        Objects.requireNonNull(sql);
+
+        return sql;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setAutoCommit(boolean autoCommit) throws SQLException {
+        ensureNotClosed();
+
+        if (autoCommit != this.autoCommit) {

Review Comment:
   Added a link.



##########
modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection2.java:
##########
@@ -0,0 +1,696 @@
+/*
+ * 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.ignite.internal.jdbc2;
+
+import static java.sql.ResultSet.CONCUR_READ_ONLY;
+import static java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT;
+import static java.sql.ResultSet.TYPE_FORWARD_ONLY;
+import static 
org.apache.ignite.internal.jdbc.proto.SqlStateCode.CONNECTION_CLOSED;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.ShardingKey;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.internal.jdbc.ConnectionProperties;
+import org.apache.ignite.internal.jdbc.JdbcDatabaseMetadata;
+import org.apache.ignite.internal.jdbc.proto.JdbcQueryEventHandler;
+import org.apache.ignite.internal.jdbc.proto.SqlStateCode;
+import org.apache.ignite.internal.lang.IgniteExceptionMapperUtil;
+import org.apache.ignite.internal.sql.SqlCommon;
+import org.apache.ignite.lang.util.IgniteNameUtils;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * {@link Connection} implementation backed by the thin client.
+ */
+public class JdbcConnection2 implements Connection {
+
+    private final IgniteClient client;
+
+    private final JdbcDatabaseMetadata metadata;
+
+    private String schemaName;
+
+    private volatile boolean closed;
+
+    private int txIsolation;
+
+    private boolean autoCommit;
+
+    private boolean readOnly;
+
+    private int networkTimeoutMillis;
+
+    /**
+     * Creates new connection.
+     *
+     * @param client Client.
+     * @param eventHandler Event handler.
+     * @param props Connection properties.
+     */
+    public JdbcConnection2(
+            IgniteClient client,
+            JdbcQueryEventHandler eventHandler,
+            ConnectionProperties props
+    ) throws SQLException {
+        autoCommit = true;
+
+        networkTimeoutMillis = props.getConnectionTimeout();
+        txIsolation = TRANSACTION_NONE;
+        schemaName = readSchemaName(props.getSchema());
+
+        this.client = client;
+        //noinspection ThisEscapedInObjectConstruction
+        metadata = new JdbcDatabaseMetadata(this, eventHandler, 
props.getUrl(), props.getUsername());
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Statement createStatement() throws SQLException {
+        return createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Statement createStatement(int resSetType, int resSetConcurrency) 
throws SQLException {
+        return createStatement(resSetType, resSetConcurrency, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Statement createStatement(int resSetType, int resSetConcurrency,
+            int resSetHoldability) throws SQLException {
+        ensureNotClosed();
+
+        checkCursorOptions(resSetType, resSetConcurrency, resSetHoldability);
+
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql) throws SQLException {
+        return prepareStatement(sql, TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int 
autoGeneratedKeys) throws SQLException {
+        ensureNotClosed();
+
+        throw new SQLFeatureNotSupportedException("Auto generated keys are not 
supported.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resSetType,
+            int resSetConcurrency) throws SQLException {
+        return prepareStatement(sql, resSetType, resSetConcurrency, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resSetType, int 
resSetConcurrency,
+            int resSetHoldability) throws SQLException {
+        ensureNotClosed();
+
+        checkCursorOptions(resSetType, resSetConcurrency, resSetHoldability);
+
+        if (sql == null) {
+            throw new SQLException("SQL string cannot be null.");
+        }
+
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int[] colIndexes) 
throws SQLException {
+        ensureNotClosed();
+
+        throw new SQLFeatureNotSupportedException("Auto generated keys are not 
supported.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, String[] colNames) 
throws SQLException {
+        ensureNotClosed();
+
+        throw new SQLFeatureNotSupportedException("Auto generated keys are not 
supported.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String nativeSQL(String sql) throws SQLException {
+        ensureNotClosed();
+
+        Objects.requireNonNull(sql);
+
+        return sql;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setAutoCommit(boolean autoCommit) throws SQLException {
+        ensureNotClosed();
+
+        if (autoCommit != this.autoCommit) {
+            this.autoCommit = autoCommit;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean getAutoCommit() throws SQLException {
+        ensureNotClosed();
+
+        return autoCommit;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void commit() throws SQLException {
+        ensureNotClosed();
+
+        if (autoCommit) {
+            throw new SQLException("Transaction cannot be committed explicitly 
in auto-commit mode.");
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void rollback() throws SQLException {
+        ensureNotClosed();
+
+        if (autoCommit) {
+            throw new SQLException("Transaction cannot be rolled back 
explicitly in auto-commit mode.");
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void rollback(Savepoint savepoint) throws SQLException {
+        ensureNotClosed();
+
+        if (savepoint == null) {
+            throw new SQLException("Invalid savepoint.");
+        }
+
+        if (autoCommit) {
+            throw new SQLException("Auto-commit mode.");

Review Comment:
   Added a link.



##########
modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection2.java:
##########
@@ -0,0 +1,696 @@
+/*
+ * 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.ignite.internal.jdbc2;
+
+import static java.sql.ResultSet.CONCUR_READ_ONLY;
+import static java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT;
+import static java.sql.ResultSet.TYPE_FORWARD_ONLY;
+import static 
org.apache.ignite.internal.jdbc.proto.SqlStateCode.CONNECTION_CLOSED;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.ShardingKey;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.internal.jdbc.ConnectionProperties;
+import org.apache.ignite.internal.jdbc.JdbcDatabaseMetadata;
+import org.apache.ignite.internal.jdbc.proto.JdbcQueryEventHandler;
+import org.apache.ignite.internal.jdbc.proto.SqlStateCode;
+import org.apache.ignite.internal.lang.IgniteExceptionMapperUtil;
+import org.apache.ignite.internal.sql.SqlCommon;
+import org.apache.ignite.lang.util.IgniteNameUtils;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * {@link Connection} implementation backed by the thin client.
+ */
+public class JdbcConnection2 implements Connection {
+
+    private final IgniteClient client;
+
+    private final JdbcDatabaseMetadata metadata;
+
+    private String schemaName;
+
+    private volatile boolean closed;
+
+    private int txIsolation;
+
+    private boolean autoCommit;
+
+    private boolean readOnly;
+
+    private int networkTimeoutMillis;
+
+    /**
+     * Creates new connection.
+     *
+     * @param client Client.
+     * @param eventHandler Event handler.
+     * @param props Connection properties.
+     */
+    public JdbcConnection2(
+            IgniteClient client,
+            JdbcQueryEventHandler eventHandler,
+            ConnectionProperties props
+    ) throws SQLException {
+        autoCommit = true;
+
+        networkTimeoutMillis = props.getConnectionTimeout();
+        txIsolation = TRANSACTION_NONE;
+        schemaName = readSchemaName(props.getSchema());
+
+        this.client = client;
+        //noinspection ThisEscapedInObjectConstruction
+        metadata = new JdbcDatabaseMetadata(this, eventHandler, 
props.getUrl(), props.getUsername());
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Statement createStatement() throws SQLException {
+        return createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Statement createStatement(int resSetType, int resSetConcurrency) 
throws SQLException {
+        return createStatement(resSetType, resSetConcurrency, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Statement createStatement(int resSetType, int resSetConcurrency,
+            int resSetHoldability) throws SQLException {
+        ensureNotClosed();
+
+        checkCursorOptions(resSetType, resSetConcurrency, resSetHoldability);
+
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql) throws SQLException {
+        return prepareStatement(sql, TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int 
autoGeneratedKeys) throws SQLException {
+        ensureNotClosed();
+
+        throw new SQLFeatureNotSupportedException("Auto generated keys are not 
supported.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resSetType,
+            int resSetConcurrency) throws SQLException {
+        return prepareStatement(sql, resSetType, resSetConcurrency, 
HOLD_CURSORS_OVER_COMMIT);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resSetType, int 
resSetConcurrency,
+            int resSetHoldability) throws SQLException {
+        ensureNotClosed();
+
+        checkCursorOptions(resSetType, resSetConcurrency, resSetHoldability);
+
+        if (sql == null) {
+            throw new SQLException("SQL string cannot be null.");
+        }
+
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int[] colIndexes) 
throws SQLException {
+        ensureNotClosed();
+
+        throw new SQLFeatureNotSupportedException("Auto generated keys are not 
supported.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public PreparedStatement prepareStatement(String sql, String[] colNames) 
throws SQLException {
+        ensureNotClosed();
+
+        throw new SQLFeatureNotSupportedException("Auto generated keys are not 
supported.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String nativeSQL(String sql) throws SQLException {
+        ensureNotClosed();
+
+        Objects.requireNonNull(sql);
+
+        return sql;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setAutoCommit(boolean autoCommit) throws SQLException {
+        ensureNotClosed();
+
+        if (autoCommit != this.autoCommit) {
+            this.autoCommit = autoCommit;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean getAutoCommit() throws SQLException {
+        ensureNotClosed();
+
+        return autoCommit;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void commit() throws SQLException {
+        ensureNotClosed();
+
+        if (autoCommit) {
+            throw new SQLException("Transaction cannot be committed explicitly 
in auto-commit mode.");
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void rollback() throws SQLException {
+        ensureNotClosed();
+
+        if (autoCommit) {
+            throw new SQLException("Transaction cannot be rolled back 
explicitly in auto-commit mode.");
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void rollback(Savepoint savepoint) throws SQLException {
+        ensureNotClosed();
+
+        if (savepoint == null) {
+            throw new SQLException("Invalid savepoint.");
+        }
+
+        if (autoCommit) {
+            throw new SQLException("Auto-commit mode.");
+        }
+
+        throw new SQLFeatureNotSupportedException("Savepoints are not 
supported.");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void close() throws SQLException {
+        if (isClosed()) {
+            return;
+        }
+
+        closed = true;
+
+        try {
+            client.close();

Review Comment:
   Thanks. Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to