https://github.com/thederickff/jsqb
Stop to lost time writing repeated SQL queries and let Java SQL Query Builder do the job for you. It's simple, fast and lightweight.
https://github.com/thederickff/jsqb
builder crud database java sql sql-query-builder
Last synced: 8 months ago
JSON representation
Stop to lost time writing repeated SQL queries and let Java SQL Query Builder do the job for you. It's simple, fast and lightweight.
- Host: GitHub
- URL: https://github.com/thederickff/jsqb
- Owner: thederickff
- Created: 2018-10-02T16:57:34.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-11T18:16:05.000Z (about 2 years ago)
- Last Synced: 2025-05-12T19:45:42.393Z (11 months ago)
- Topics: builder, crud, database, java, sql, sql-query-builder
- Language: Java
- Homepage:
- Size: 35.2 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
SQL Query Builder
=================
Stop to lost time writing repeated SQL queries and let Java SQL Query Builder do the job for you. It's simple, fast and lightweight. **You don't need to make a connection with a database.**
* [1. Installation](#block1)
* [1.1. Installation with Maven](#block1.1)
* [2. SELECT Statement](#block2)
* [2.1. Basic SELECT statement](#block2.1)
* [2.2. SELECT with Specific Fields statement](#block2.2)
* [2.3. Aliased SELECT statement](#block2.3)
* [3. INNER JOIN statement](#block3)
* [3.1 Simple Inner join](#block3.1)
* [4. Author](#block4)
* [5. License](#block5)
## 1. Installation [↑](#index_block)
For default installation, see [Releases](https://github.com/derickfelix/jsqb/releases) section to download the .jar file and add it to the path of your project.
### 1.1. Installation with Maven [↑](#index_block)
To install with maven, you can use the [Jitpack](https://jitpack.io/) for that.
Step 1. Add the JitPack repository to your build file
```xml
...
jitpack.io
https://jitpack.io
```
Step 2. Add the dependency
```xml
...
com.github.derickfelix
jsqb
LATEST
```
If the project doesn't have any GitHub Releases you can use the short commit hash or 'master-SNAPSHOT' as the version. Check the [Jitpack](https://jitpack.io/) page for more details.
## 2. SELECT Statement [↑](#index_block)
### 2.1. Basic SELECT statement [↑](#index_block)
#### Usage:
```java
public class Usage {
public static void main(String[] args)
{
Jsqb jsqb = new Jsqb();
String sql = jsqb.select("users").write();
System.out.println(sql);
}
}
```
#### Output:
```sql
SELECT users.* FROM users
```
### 2.2. SELECT with Specific Fields [↑](#index_block)
#### Usage:
```java
public class Usage {
public static void main(String[] args)
{
Jsqb jsqb = new Jsqb();
String sql = jsqb.select("users", "id", "name", "email").write();
System.out.println(sql);
}
}
```
#### Output:
```sql
SELECT users.id, users.name, users.email FROM users
```
### 2.2. Aliased SELECT statement [↑](#index_block)
The same of the previous one but with more information.
#### Usage:
```java
public class Usage {
public static void main(String[] args)
{
Jsqb jsqb = new Jsqb();
String sql = jsqb.select("users", "id as userId", "name as username", "email as receiver").write();
System.out.println(sql);
}
}
```
#### Output:
```sql
SELECT users.id as userId, users.name as username, users.email as receiver FROM users
```
## 3. INNER JOIN statement [↑](#index_block)
### 3.1. Simple Inner join [↑](#index_block)
The `innerJoin()` method expects the `tableName`, and the `on` detail, and the `fields` parameter is optional.
This method is described as:
`innerJoin(String tableName, String on, String... fields)`.
#### Usage:
```java
public class Usage {
public static void main(String[] args)
{
Jsqb jsqb = new Jsqb();
String sql = jsqb.select("users", "id", "name", "email")
.innerJoin("roles", "roles.id = users.role_id", "name", "level")
.write();
System.out.println(sql);
}
}
```
#### Output:
```sql
SELECT users.id, users.name, users.email, roles.name, roles.level FROM users
INNER JOIN roles on roles.id = users.role_id
```
## 4. Author [↑](#index_block)
Derick Felix
-
- [https://github.com/derickfelix](https://github.com/derickfelix)
## 5. License [↑](#index_block)
Java SQL Query Builder is licensed under the Apache license.
```
Copyright 2018 derickfelix.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```