Custom Adapter
Hint
This article is generated by AI translation.
With dbvisitor-driver, developers can more easily extend data source support, enabling applications to access various types of databases in a unified way. It is designed for the following scenarios:
- Integrating non-relational databases into JDBC-based applications.
- Projects that need to provide JDBC interfaces for custom data sources.
Architecture Design
The project adopts an interface-oriented design pattern, consisting of the following core components:
- Driver Entry
net.hasor.dbvisitor.driver.JdbcDriverimplements thejava.sql.Driverinterface, responsible for URL parsing and creating supported connections.- The driver entry class mandates that all adapters follow the JDBC URL format:
jdbc:dbvisitor:<adapterName>//<server?param=value>
- Adapter Manager
- The
net.hasor.dbvisitor.driver.AdapterManagerclass manages and loads adapter factories, using the Java SPI mechanism to discover and register adapters.
- The
- JDBC Standard Implementation Layer
- All classes prefixed with
Jdbcunder thenet.hasor.dbvisitor.driver.*package implement JDBC standard interfaces.
- All classes prefixed with
- Adapter Layer
- The
net.hasor.dbvisitor.driver.AdapterFactoryinterface is the adapter connection factory, responsible for creatingAdapterConnectioninstances. - The
net.hasor.dbvisitor.driver.AdapterConnectionabstract class is the adapter connection, handling adapter requests and responses.
- The
- Type Support
- TypeSupport, AdapterTypeSupport: Provide data type conversion support
- ConvertUtils: Utility class for handling various data type conversions
Technical Features
- SPI Mechanism: Dynamically loads adapters through the Java SPI mechanism, achieving a loosely coupled plugin architecture.
- Type Conversion: Provides a flexible type conversion system supporting mappings between various data types.
- Request/Response Model: Adopts a request/response model for database operations, facilitating adaptation to various data sources.
- Compatibility: Strives for compatibility with standard JDBC interfaces, with some limitations.