Skip to content

TDMinhNhat/generate-database-library

Repository files navigation

📦 Generate Database Library

A lightweight Java library to help generate and initialize database structures programmatically — useful for rapid development, prototyping, or automating schema setups.

Maven Central javadoc License: MIT

🛠️ Installation

With Maven

<dependency>
  <groupId>io.github.tdminhnhat</groupId>
  <artifactId>generate-database-library</artifactId>
  <version>1.0.0</version>
</dependency>

With Gradle

Gradle Kotlin

implementation("io.github.tdminhnhat:generate-database:1.0.0")

Gradle Groovy Short

implementation 'io.github.tdminhnhat:generate-database:1.0.0'

Gradle Groovy Long

implementation group: 'io.github.tdminhnhat', name: 'generate-database', version: '1.0.0'

💡 Usage

Interact with GUI

Sample the main function to work

public static void main(String[] args) {
    GenerateDatabaseService.showGUI();
}

Or you can call show GUI later, put this one somewhere and remember call the function contain this:

GenerateDatabaseService.showGUI();

Interact with Code (Complex)

You have to work with both of them service. Every feature on this library in GenerateDatabaseService and this one needs some datas to work and you can find it in TopicService. Remember all the functions are static, so you can call direct with class name instead of initial.

TopicService:

  1. Get all the default topics. These topics were created by the authors.
String[] listTopics = TopicService().getListDefaultTopics();
  1. Get all the users who have developed and create their topic in this library.
String[] listUsers = TopicService().getListUsers();
  1. Get all the topics from the author by point that username.
String[] listTopicsByUser = TopicService().getListTopicsByUser(username);
  1. Get all the classes which they're relating to work JPA Entity. In this function, the parameter 'username' that you can put null value and 'topic' must be existed value.
List<Class<?>> listClasses = TopicService().getListClassWorkJPATopic(username, topic);
  1. Get list classes information by username and topic.
List<EntityInformation> listEntityInformations = TopicService().getListClassTopic(username, topic);
  1. Get content class. The content include: class name, fields, functions,... like a source java code.
String content = TopicService().getContentClass(packageName, className);

GenerateDatabaseTopic:

  1. Show the UI to the user can interact.
GenerateDatabaseService.showGUI();
  1. Test connect to database server
//databaseInformation: DatabaseInformation
boolean result = GenerateDatabaseService.testConnection(databaseInformation);
  1. Generate database, create tables, columns but make sure you have to connect to database successfully else it's throw exception.
//databaseInformation: DatabaseInformation
//classes: List<Class<?>>
EntityManager em = GenerateDatabaseService.generateDatabase(databaseInformation, classes)
  1. Export the source code java and save into your disk
String message = GenerateDatabaseSerivce.exportClass(pathSave, packageScanning);

📄 Documentation

📖 API Documentation: View Javadoc

💻 Develop library

Want to become a contribution in this project. Read carefully in this document.

About

A library allows you can generate database

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages