JDolt
JDolt is a Java client library for Dolt, a SQL database with Git-like version control capabilities. This project provides a high-level API for interacting with Dolt databases, allowing you to perform version control operations on your database similar to Git operations on code.
Project Overview
JDolt encapsulates Dolt's version control functionality into a Java API, making it easy to integrate database version control into your Java applications. It provides methods for common version control operations like commit, branch, merge, pull, push, and more.
Modules
The project consists of two main modules:
-
jdolt-core: Contains the core functionality for interacting with Dolt databases, including:
- API interfaces and implementations
- Version control operations
- Database connection management
-
jdolt-service: A Spring Boot application that provides a service layer on top of jdolt-core.
Features
JDolt supports a wide range of Dolt version control operations, including:
- Branch management (create, list, delete)
- Commit changes
- Checkout branches or commits
- Merge branches
- Pull and push changes
- Reset and revert changes
- Conflict resolution
- Diff and status operations
- And many more
Getting Started
Prerequisites
- Java 17 or higher
- Maven
- Access to a Dolt database
Installation
-
Clone the repository:
git clone https://github.com/yourusername/JDolt.git
-
Build the project with Maven:
cd JDolt
mvn clean install
Configuration
Configure your Dolt database connection in your application. If using the jdolt-service module, you can configure it in the application.yaml file:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: your_username
password: your_password
url: jdbc:mysql://your_dolt_server:port/your_database
Usage Example
Here's a simple example of how to use JDolt in your Java application:
DataSource dataSource =
DoltClient doltClient = DoltClient.initialize(dataSource);
VersionControl versionControl = doltClient.versionControl();
versionControl.doltBranch().prepare()
.createBranch("new-feature")
.execute();
versionControl.doltCheckout().prepare()
.branch("new-feature")
.execute();
versionControl.doltCommit().prepare()
.message("Added new feature")
.execute();
Project Structure
JDolt/
βββ doc/
β βββ codeTemplates/ # Code templates for creating Dolt components
βββ jdolt-core/ # Core library module
β βββ src/
β βββ main/
β β βββ java/
β β βββ com/
β β βββ hxuanyu/
β β βββ jdolt/
β β βββ core/ # Core functionality
β β βββ manager/ # Connection management
β β βββ util/ # Utility classes
β βββ test/ # Unit tests
βββ jdolt-service/ # Spring Boot service module
β βββ src/
β βββ main/
β β βββ java/
β β β βββ com/
β β β βββ hxuanyu/
β β β βββ jdolt/
β β β βββ DoltManagerApplication.java
β β βββ resources/
β β βββ application.yaml
β βββ test/ # Unit tests
βββ pom.xml # Maven parent POM
Dependency
You can add JDolt to your project directly from Maven Central:
<dependency>
<groupId>com.hxuanyu.doltmanager</groupId>
<artifactId>jdolt-core</artifactId>
<version>1.0.1</version>
</dependency>
Contribution
Contributions are welcome! Please open issues or pull requests on GitHub.
License
JDolt is licensed under the Apache License 2.0. See the LICENSE file for details.
Acknowledgments
- Dolt - The SQL database with Git-like version control
- The developers and contributors to this project
For more information, usage examples, and advanced features, please refer to the Wiki or the δΈζζζ‘£.