Skip to main content

dbVisitor

One APIs Access Any DataBase

Acknowledge differences, manage differences, not eliminate them — through a dual-layer adapter architecture, one set of APIs naturally accesses any database.

Broad Database Support

Covers 11 relational database dialects, plus NoSQL and vector databases via JDBC driver adapters

MySQL
PostgreSQL
Oracle
SQL Server
DB2
ClickHouse
TiDB
OceanBase
DM
StarRocks
Doris
Redis
MongoDB
Elasticsearch
Milvus

Core Philosophy

Use different levels of API to solve different levels of problems — respect and manage data source differences.

🔗
Unified APIs
Programmatic, Declarative, Mapper, XML File — 5 API styles
📐
Dual-Layer Adapter Architecture
Application access layer, standard driver layer, independent evolution, independent use
🧩
Zero Coupling
Complex or simple, free integration, use anywhere

Dual-Layer Adapter Architecture

Application layer manages query differences, Protocol layer manages communication differences

Dual-Layer Adapter Architecture

5 API Styles

Choose the best API for your scenario — all styles share the same underlying runtime mechanism.

⌨️

JdbcTemplate

Native SQL operations, the most direct way to access databases

View Docs
JdbcTemplate.java
JdbcTemplate jdbc = new JdbcTemplate(dataSource);

// Query and map to Bean
List<User> users = jdbc.queryForList(
    "select * from users where age > ?",
    User.class,
    new Object[] { 18 }
);

// Query single value
Long total = jdbc.queryForObject(
    "select count(*) from users",
    Long.class
);

Same APIs, Different Databases

Whether the underlying database is MySQL or MongoDB, the application code stays the same

MySQL / PostgreSQL
// Connect to relational database
Configuration config = new Configuration();
LambdaTemplate t = config.newLambda(ds);

// Lambda query
List<User> users = t
    .lambdaQuery(User.class)
    .eq(User::getAge, 18)
    .list();
MongoDB / Elasticsearch
// Connect to NoSQL database (same API)
Configuration config = new Configuration();
LambdaTemplate t = config.newLambda(ds);

// Exact same Lambda query
List<User> users = t
    .lambdaQuery(User.class)
    .eq(User::getAge, 18)
    .list();

Quick Start

Just one Maven dependency to get started

pom.xml
<dependency>
  <groupId>net.hasor</groupId>
  <artifactId>dbvisitor</artifactId>
  <version>6.7.0</version>
</dependency>