A lightweight Java library to help generate and initialize database structures programmatically — useful for rapid development, prototyping, or automating schema setups.
<dependency>
<groupId>io.github.tdminhnhat</groupId>
<artifactId>generate-database-library</artifactId>
<version>1.0.0</version>
</dependency>
implementation("io.github.tdminhnhat:generate-database:1.0.0")
implementation 'io.github.tdminhnhat:generate-database:1.0.0'
implementation group: 'io.github.tdminhnhat', name: 'generate-database', version: '1.0.0'
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();
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.
- Get all the default topics. These topics were created by the authors.
String[] listTopics = TopicService().getListDefaultTopics();
- Get all the users who have developed and create their topic in this library.
String[] listUsers = TopicService().getListUsers();
- Get all the topics from the author by point that username.
String[] listTopicsByUser = TopicService().getListTopicsByUser(username);
- 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);
- Get list classes information by username and topic.
List<EntityInformation> listEntityInformations = TopicService().getListClassTopic(username, topic);
- Get content class. The content include: class name, fields, functions,... like a source java code.
String content = TopicService().getContentClass(packageName, className);
- Show the UI to the user can interact.
GenerateDatabaseService.showGUI();
- Test connect to database server
//databaseInformation: DatabaseInformation
boolean result = GenerateDatabaseService.testConnection(databaseInformation);
- 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)
- Export the source code java and save into your disk
String message = GenerateDatabaseSerivce.exportClass(pathSave, packageScanning);
📖 API Documentation: View Javadoc
Want to become a contribution in this project. Read carefully in this document.