Skip to content

Easily access your database in many plugins with minimal configuration

Notifications You must be signed in to change notification settings

playajames419/EasyDatabaseConnector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EasyDatabaseConnector

Easily access your database in many plugins with minimal configuration

Description

This API allows developers to access a database across multiple plugins by simply adding the API as a dependency to their projects. Configure once, use on any project!

Features

  • Object oriented database access using Jooq
  • Connection pool and cache management using HikariCP
  • Very efficient
  • Safe and secure
  • Lightweight

Getting Started

Dependencies

  • Spigot/Paper/etc API or similar
  • MySQL database

Setup

  • Fork or clone this repository
  • Modify the pom.xml with your database details
    <url>jdbc:mysql://localhost:3306/database-name</url>      <!-- Put database host:port/database-name here -->
    <user>username</user>                                     <!-- Put database username here -->
    <password>password</password>                             <!-- Put database password here -->
    
    <inputSchema>database-name</inputSchema>                            <!-- Put database name here -->

Generating Jooq Classes

Note: Jooq uses a plugin to generate classes that allow you to access your database. Any time you make changes to your database structure(Add tables, modify colunms, etc.) You will need to regenerate these classes.

This Jooq Code Generation Manual will show you how to generate code.

Generate Jooq Classes Using InteliJ

  • Open your maven tool window
  • Expand for Plugins section
  • Expand jooq-codegen section
  • Double click jooq-codegen:generate
  • Build the project

Accessing Your Database

  • Add the compiled project as a dependency to your project
  • You now have access to HikariCP and Jooq classes.

Using Jooq with HikariCP

  • Create a DSLContext variable
DSLContext context = DSL.using(HikariCPFactory.getDataSource(), SQLDialect.MYSQL);

Help

Contact me on Discord(Playajames#5723) or create an issue.

Authors

Contributors names and contact info

  • playajames(Discord: Playajames#5723)

Version History

  • 1.0-SNAPSHOT
    • Initial Release

License

This project is licensed under the GPL-3.0 License.

Acknowledgments

Inspiration, code, snippets, etc.

About

Easily access your database in many plugins with minimal configuration

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages