• 开发自己的jdbc驱动——基本说明


    jdbc目前支持4种类型的驱动模式
    参考如下图,我们需要开发的是type4 100%纯java代码的,以下只是简单的原型,实现一个比较完整的jdbc驱动,后续会逐步完成

    项目结构

    当前没有依赖任何三方包,对于包含了依赖的,对于驱动的如果使用maven项目推荐使用maven-shade-plugin 插件,尽管这样开发的驱动
    比较大,但是可靠性以及稳定性比较好(减少依赖包冲突)

    • maven 项目结构
     
    ├── pom.xml
    └── src
        ├── main
        │   ├── java
        │   │   └── com
        │   │       └── dalong
        │   │           └── jdbc
        │   │               ├── MyConnection.java
        │   │               ├── MyDatabaseMetaData.java
        │   │               └── MyDriver.java
        │   └── resources
        │       └── META-INF
        │           └── services
        │               └── java.sql.Driver
        └── test
            └── java
    • 简单说明
      resources/META-INF/services/java.sql.Driver 这个文件是jdbc驱动开发的一个约定(spi),内容很简单(指定我们驱动的完整类名就可以了)
     
    com.dalong.jdbc.MyDriver

    pom.xml 这个很简单,没有什么特殊的,后期开发其他依赖的时候可能就需要扩展了

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.dalong</groupId>
        <artifactId>myjdbc</artifactId>
        <version>1.0-SNAPSHOT</version>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <encoding>UTF-8</encoding>
            <java.version>1.8</java.version>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
        </properties>
    </project>
     
     

    MyDriver.java driver 接口的实现,一个通用的模式

    package com.dalong.jdbc;
    import java.io.Closeable;
    import java.io.IOException;
    import java.sql.*;
    import java.util.Properties;
    import java.util.logging.Logger;
    /**
     @author dalong
     mydemo jdbc driver for http tet
     */
    public class MyDriver  implements Driver, Closeable {
        static final String DRIVER_NAME = "my JDBC Driver";
        static final String DRIVER_VERSION;
        static final int DRIVER_VERSION_MAJOR;
        static final int DRIVER_VERSION_MINOR;
        private static final String DRIVER_URL_START = "jdbc:myapp:";
        static   {
            // 我们通过静态构造函数注册我们的驱动,如果了解golang 的sql 驱动的话,也是一样的,支持golang 基于了 init 函数进行驱动的注册
            try {
                DRIVER_VERSION_MAJOR= 3;
                DRIVER_VERSION_MINOR =1;
                DRIVER_VERSION = "1.0.0";
                MyDriver driver = new MyDriver();
                DriverManager.registerDriver(driver);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
        @Override
        public void close() throws IOException {
            // http connect demo
        }
        // implements connect   manage connect
        @Override
        public Connection connect(String url, Properties info) throws SQLException {
            // first check url is validate
            if (acceptsURL(url)){
                return  new MyConnection(url,info);
            }
            return null;
        }
        @Override
        public boolean acceptsURL(String url) throws SQLException {
           return url.startsWith(DRIVER_URL_START);
        }
        @Override
        public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
            return new DriverPropertyInfo[0];
        }
        @Override
        public int getMajorVersion() {
            return DRIVER_VERSION_MAJOR;
        }
        @Override
        public int getMinorVersion() {
            return DRIVER_VERSION_MINOR;
        }
        @Override
        public boolean jdbcCompliant() {
            return false;
        }
        @Override
        public Logger getParentLogger() throws SQLFeatureNotSupportedException {
            return null;
        }
    }

    MyConnection.java 我们所有的操作都是基于connection 的,此代码比较简单,没有添加特殊的东西,主要是关于
    DatabaseMetaData的返回(方便尝试的,后边继续完整)

     
    package com.dalong.jdbc;
    import java.sql.*;
    import java.util.Map;
    import java.util.Properties;
    import java.util.concurrent.Executor;
    /**
     @author dalong
     实现一个jdbc connection 包装 http 请求
    */
    public class MyConnection implements Connection {
        // atomic operators
        MyConnection(String url,Properties properties) {
        }
        @Override
        public Statement createStatement() throws SQLException {
            return null;
        }
        @Override
        public PreparedStatement prepareStatement(String sql) throws SQLException {
            return null;
        }
        @Override
        public CallableStatement prepareCall(String sql) throws SQLException {
            return null;
        }
        @Override
        public String nativeSQL(String sql) throws SQLException {
            // 输出原始sql
            return sql;
        }
        //  事务支持
        @Override
        public void setAutoCommit(boolean autoCommit) throws SQLException {
        }
        @Override
        public boolean getAutoCommit() throws SQLException {
            return false;
        }
        @Override
        public void commit() throws SQLException {
        }
        @Override
        public void rollback() throws SQLException {
        }
        @Override
        public void close() throws SQLException {
        }
        @Override
        public boolean isClosed() throws SQLException {
            return false;
        }
      // 返回元数据信息,通过自己实现的MyDatabaseMetaData 完成部分
        @Override
        public DatabaseMetaData getMetaData() throws SQLException {
            // 可以通过约定获取
            return new MyDatabaseMetaData();
        }
        @Override
        public void setReadOnly(boolean readOnly) throws SQLException {
        }
        @Override
        public boolean isReadOnly() throws SQLException {
            return true;
        }
        @Override
        public void setCatalog(String catalog) throws SQLException {
        }
        @Override
        public String getCatalog() throws SQLException {
            return null;
        }
        @Override
        public void setTransactionIsolation(int level) throws SQLException {
        }
        @Override
        public int getTransactionIsolation() throws SQLException {
            return 0;
        }
        @Override
        public SQLWarning getWarnings() throws SQLException {
            return null;
        }
        @Override
        public void clearWarnings() throws SQLException {
        }
        @Override
        public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
            return null;
        }
        @Override
        public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
            return null;
        }
        @Override
        public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
            return null;
        }
        @Override
        public Map<String, Class<?>> getTypeMap() throws SQLException {
            return null;
        }
        @Override
        public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
        }
        @Override
        public void setHoldability(int holdability) throws SQLException {
        }
        @Override
        public int getHoldability() throws SQLException {
            return 0;
        }
        @Override
        public Savepoint setSavepoint() throws SQLException {
            return null;
        }
        @Override
        public Savepoint setSavepoint(String name) throws SQLException {
            return null;
        }
        @Override
        public void rollback(Savepoint savepoint) throws SQLException {
        }
        @Override
        public void releaseSavepoint(Savepoint savepoint) throws SQLException {
        }
        @Override
        public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
            return null;
        }
        @Override
        public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
            return null;
        }
        @Override
        public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
            return null;
        }
        @Override
        public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
            return null;
        }
        @Override
        public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
            return null;
        }
        @Override
        public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
            return null;
        }
        @Override
        public Clob createClob() throws SQLException {
            return null;
        }
        @Override
        public Blob createBlob() throws SQLException {
            return null;
        }
        @Override
        public NClob createNClob() throws SQLException {
            return null;
        }
        @Override
        public SQLXML createSQLXML() throws SQLException {
            return null;
        }
        @Override
        public boolean isValid(int timeout) throws SQLException {
            return false;
        }
        @Override
        public void setClientInfo(String name, String value) throws SQLClientInfoException {
        }
        @Override
        public void setClientInfo(Properties properties) throws SQLClientInfoException {
        }
        @Override
        public String getClientInfo(String name) throws SQLException {
            return null;
        }
        @Override
        public Properties getClientInfo() throws SQLException {
            return null;
        }
        @Override
        public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
            return null;
        }
        @Override
        public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
            return null;
        }
        @Override
        public void setSchema(String schema) throws SQLException {
            throw new SQLFeatureNotSupportedException();
        }
        @Override
        public String getSchema() throws SQLException {
            throw new SQLFeatureNotSupportedException();
        }
        @Override
        public void abort(Executor executor) throws SQLException {
            throw new SQLFeatureNotSupportedException();
        }
        @Override
        public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
        }
        @Override
        public int getNetworkTimeout() throws SQLException {
            return 0;
        }
        @Override
        public <T> T unwrap(Class<T> iface) throws SQLException {
            return null;
        }
        @Override
        public boolean isWrapperFor(Class<?> iface) throws SQLException {
            return false;
        }
    }

    MyDatabaseMetaData.java 元数据暴露的,代码很简单,主要是提供了用户在连接的时候提示信息

    package com.dalong.jdbc;
    import java.sql.*;
    /**
     * @author dalong
     */
    public class MyDatabaseMetaData implements DatabaseMetaData {
        @Override
        public boolean allProceduresAreCallable() throws SQLException {
            return false;
        }
        @Override
        public boolean allTablesAreSelectable() throws SQLException {
            return false;
        }
        @Override
        public String getURL() throws SQLException {
            return null;
        }
        @Override
        public String getUserName() throws SQLException {
            return null;
        }
        @Override
        public boolean isReadOnly() throws SQLException {
            return false;
        }
        @Override
        public boolean nullsAreSortedHigh() throws SQLException {
            return false;
        }
        @Override
        public boolean nullsAreSortedLow() throws SQLException {
            return false;
        }
        @Override
        public boolean nullsAreSortedAtStart() throws SQLException {
            return false;
        }
        @Override
        public boolean nullsAreSortedAtEnd() throws SQLException {
            return false;
        }
        @Override
        public String getDatabaseProductName() throws SQLException {
            return "my server 1.0.0";
        }
        @Override
        public String getDatabaseProductVersion() throws SQLException {
            return "my server 1.0.0";
        }
        @Override
        public String getDriverName() throws SQLException {
            return "myjdbc for my server";
        }
        @Override
        public String getDriverVersion() throws SQLException {
            return "1.0.0";
        }
        @Override
        public int getDriverMajorVersion() {
            return MyDriver.DRIVER_VERSION_MAJOR;
        }
        @Override
        public int getDriverMinorVersion() {
            return MyDriver.DRIVER_VERSION_MINOR;
        }
        @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 false;
        }
        @Override
        public boolean storesMixedCaseIdentifiers() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
            return false;
        }
        @Override
        public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
            return false;
        }
        @Override
        public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
            return false;
        }
        @Override
        public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
            return false;
        }
        @Override
        public String getIdentifierQuoteString() throws SQLException {
            return null;
        }
        @Override
        public String getSQLKeywords() throws SQLException {
            return null;
        }
        @Override
        public String getNumericFunctions() throws SQLException {
            return null;
        }
        @Override
        public String getStringFunctions() throws SQLException {
            return null;
        }
        @Override
        public String getSystemFunctions() throws SQLException {
            return null;
        }
        @Override
        public String getTimeDateFunctions() throws SQLException {
            return null;
        }
        @Override
        public String getSearchStringEscape() throws SQLException {
            return null;
        }
        @Override
        public String getExtraNameCharacters() throws SQLException {
            return null;
        }
        @Override
        public boolean supportsAlterTableWithAddColumn() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsAlterTableWithDropColumn() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsColumnAliasing() throws SQLException {
            return false;
        }
        @Override
        public boolean nullPlusNonNullIsNull() throws SQLException {
            return false;
        }
        @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 false;
        }
        @Override
        public boolean supportsDifferentTableCorrelationNames() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsExpressionsInOrderBy() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsOrderByUnrelated() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsGroupBy() throws SQLException {
            return false;
        }
        @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 false;
        }
        @Override
        public boolean supportsCoreSQLGrammar() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsExtendedSQLGrammar() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsANSI92EntryLevelSQL() throws SQLException {
            return false;
        }
        @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 false;
        }
        @Override
        public boolean supportsFullOuterJoins() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsLimitedOuterJoins() throws SQLException {
            return false;
        }
        @Override
        public String getSchemaTerm() throws SQLException {
            return null;
        }
        @Override
        public String getProcedureTerm() throws SQLException {
            return null;
        }
        @Override
        public String getCatalogTerm() throws SQLException {
            return null;
        }
        @Override
        public boolean isCatalogAtStart() throws SQLException {
            return false;
        }
        @Override
        public String getCatalogSeparator() throws SQLException {
            return null;
        }
        @Override
        public boolean supportsSchemasInDataManipulation() throws SQLException {
            return false;
        }
        @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 false;
        }
        @Override
        public boolean supportsSubqueriesInExists() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsSubqueriesInIns() throws SQLException {
            return false;
        }
        @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 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;
        }
        @Override
        public int getDefaultTransactionIsolation() throws SQLException {
            return 0;
        }
        @Override
        public boolean supportsTransactions() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsTransactionIsolationLevel(int level) 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 ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getSchemas() throws SQLException {
            return null;
        }
        @Override
        public ResultSet getCatalogs() throws SQLException {
            return null;
        }
        @Override
        public ResultSet getTableTypes() throws SQLException {
            return null;
        }
        @Override
        public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getTypeInfo() throws SQLException {
            return null;
        }
        @Override
        public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException {
            return null;
        }
        @Override
        public boolean supportsResultSetType(int type) throws SQLException {
            return false;
        }
        @Override
        public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException {
            return false;
        }
        @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 supportsBatchUpdates() throws SQLException {
            return false;
        }
        @Override
        public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException {
            return null;
        }
        @Override
        public Connection getConnection() throws SQLException {
            return null;
        }
        @Override
        public boolean supportsSavepoints() 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 ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) throws SQLException {
            return null;
        }
        @Override
        public boolean supportsResultSetHoldability(int holdability) throws SQLException {
            return false;
        }
        @Override
        public int getResultSetHoldability() throws SQLException {
            return 0;
        }
        @Override
        public int getDatabaseMajorVersion() throws SQLException {
            return 0;
        }
        @Override
        public int getDatabaseMinorVersion() throws SQLException {
            return 0;
        }
        @Override
        public int getJDBCMajorVersion() throws SQLException {
            return 0;
        }
        @Override
        public int getJDBCMinorVersion() throws SQLException {
            return 0;
        }
        @Override
        public int getSQLStateType() throws SQLException {
            return 0;
        }
        @Override
        public boolean locatorsUpdateCopy() throws SQLException {
            return false;
        }
        @Override
        public boolean supportsStatementPooling() throws SQLException {
            return false;
        }
        @Override
        public RowIdLifetime getRowIdLifetime() throws SQLException {
            return null;
        }
        @Override
        public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
            return null;
        }
        @Override
        public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
            return false;
        }
        @Override
        public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
            return false;
        }
        @Override
        public ResultSet getClientInfoProperties() throws SQLException {
            return null;
        }
        @Override
        public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException {
            return null;
        }
        @Override
        public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
            return null;
        }
        @Override
        public boolean generatedKeyAlwaysReturned() throws SQLException {
            return false;
        }
        @Override
        public <T> T unwrap(Class<T> iface) throws SQLException {
            return null;
        }
        @Override
        public boolean isWrapperFor(Class<?> iface) throws SQLException {
            return false;
        }
    }

    连接试用

    很简单,我们基于dbeaver 配置我们自己开发的驱动进行连接

    • 构建jar包
    mvn clean package
    • 添加新的dbeaver驱动配置


    • 使用自己的驱动进行连接测试

    说明

    以上代码很简单,主要是关于jdbc驱动开发的基本原型的说明,后边我们基于此开发一个http请求处理的jdbc驱动,如果经常看一些
    开源项目的话,应该会发现开源项目的额jdbc驱动开发的模式也是按照这个套路的,有些是封装的底层协议,有些封装的是http协议

    参考资料

    https://github.com/prestodb/presto/tree/master/presto-jdbc
    https://github.com/h2database/h2database/blob/master/h2/src/main/org/h2/Driver.java

  • 相关阅读:
    SSH 免密登录配置
    Hadoop 2.7.2 集群安装配置
    将oracle数据库中数据写入excel文件
    PLSQL提交请求集
    oracle会计工作总结,EBS 创建会计科目 小结
    将oracle数据库中数据写入excel文件
    如何成为一名优秀的工程师(听讲座有感) Winema
    基于W5300的嵌入式以太网接口设计 Winema
    Java 基础入门随笔(2) JavaSE版——关键字、进制转换、类型转换
    VMware 11安装Mac OS X 10.10 及安装Mac Vmware Tools.
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/13788390.html
Copyright © 2020-2023  润新知