https://github.com/tharos70/jdbc-swiss-knife
A simple set of utilities for handling jdbc accessible metadata.
https://github.com/tharos70/jdbc-swiss-knife
dao generator java jdbc postgresql
Last synced: 2 months ago
JSON representation
A simple set of utilities for handling jdbc accessible metadata.
- Host: GitHub
- URL: https://github.com/tharos70/jdbc-swiss-knife
- Owner: tharos70
- License: mit
- Created: 2021-05-14T16:31:17.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-08-07T15:25:50.000Z (almost 5 years ago)
- Last Synced: 2024-11-16T03:13:51.296Z (over 1 year ago)
- Topics: dao, generator, java, jdbc, postgresql
- Language: Java
- Homepage:
- Size: 135 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.com/tharos70/jdbc-swiss-knife)

# jdbc-swiss-knife
> A simple set of utilities for handling jdbc accessible metadata.
It includes:
- Database metadata reader
- Database metadata based java code generator supporting:
- spring-jdbc Dao basic implementation
> So far, the only supported database is [Posgresql](https://www.postgresql.org/). Anyway, it should be easy to extend the support to other jdbc compliant platforms
## Installing / Getting started
Simply add the following dependency to you `pom.xml`
```xml
com.tharos
jdbc-swiss-knife
${version}
```
## How to
### - Read metadata from DB
```java
DatabaseMetadataExtractor dbme = new DatabaseMetadataExtractor(
"org.postgresql.Driver",
"jdbc:postgresql://localhost:5432/postgres",
"user",
"password",
"schema-name"
);
//Retrieves all tables in schema
ArrayList tableList = dbme.getTablesList();
....
//Retrieves all columns for tableName
ArrayList columnList = dbme.extractColumnsInfo("tableName");
```
### - Generate spring-jdbc framework based Dao Classes
```java
...
Table t = dbme.getTablesList().get(0);
new DaoPatternStrategy()
.generate(
t,
"base.package", // base package for generated classes
new File("/path/to/output/folder")
);
```
### - Generate spring-jdbc framework based configuration
```java
...
List tableList = dbme.getTablesList();
new SpringConfigurationGenerator(
tableList,
"base.package",
new File("/path/to/output/folder")
).generate();
```
## Developing
If you want to extend this library just run the following command
```shell
git clone https://github.com/tharos70/jdbc-swiss-knife.git
```
### Building
In order to build the project just install [maven](https://maven.apache.org/) and a java 11 compatible sdk (such as [adoptOpenJdk](https://adoptopenjdk.net/)) in your system and run the following command
```shell
cd jdbc-swiss-knife
mvn clean install
```
Now you can add you own functionality to the library with your favourite IDE.
## Contributing
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.
## Links
- Project homepage: https://github.com/tharos70/jdbc-swiss-knife
- Repository: https://github.com/tharos70/jdbc-swiss-knife
- Issue tracker: https://github.com/tharos70/jdbc-swiss-knife/issues
- In case of sensitive bugs like security vulnerabilities, please contact
tharos70@gmail.com directly instead of using issue tracker. We value your effort to improve the security and privacy of this project!
- Related projects:
> This project relies on the amazing [Javapoet](https://github.com/square/javapoet) library. A huge thanks to *square* for creating such an amazing tool.
## Project status
This project is considered *under construction* so use it carefully and at your own risk.
## Licensing
All the code in this project is licensed under Apache License 2.0 license.
## Publishing
https://s01.oss.sonatype.org/#stagingRepositories