Welcome to JSQL. It's a lightweight JDBC DSL framework, JSQL means Just SQL
and without ORM configuration.
It is a framework which is convenience and easy to use, just like sql syntax that you feel free to write SQL as usual and
makes Java SQL development more easier.
If you are a Java developer searching for the jdbc framework satisfy functions as connection pool, super lightweight orm and want to write sql like java code programing, then I suggest you could try to use JSQL framework for jdbc operation.
JSQL for Reasons:
- No SQL string and keep your code graceful
- No ORM bean code generation mass your git control
- Provide ExecutorPool/ConnectionPool for jdbc connection pooling without DBCP dependencies
- JDK6 or higher
- Connection/JdbcExecutor pool
- SQL syntax like builder
- Transaction
- Support customizing dialects
- Pagination
- Jdbc executor for query, update or batch update
- Super lightweight ORM
- Against SQL inject
- Logging ability
- Cubrid
- SQLite
- DB2
- Derby (EmbeddedDerby/NetworkDerby)
- H2
- MariaDB
- MySQL
- Oracle
- PostgreSQL
- SQLServer2012(version >= 2012)
<!-- for jdk1.8+ -->
<dependency>
<groupId>cn.icuter</groupId>
<artifactId>jsql</artifactId>
<version>1.1.2</version>
</dependency>
<!-- for jdk1.6+ -->
<dependency>
<groupId>cn.icuter</groupId>
<artifactId>jsql-jdk1.6</artifactId>
<version>1.1.2</version>
</dependency>
JSQLDataSource dataSource = JSQLDataSource.newDataSourceBuilder()
.url("jdbcUrl").user("jsql").password("pass").build();
List<Map<String, Object>> list = dataSource.select()
.from("table")
.where().eq("name", "jsql")
.execQuery();
SQL: select * from table where name = ?
Value: [jsql]
JSQLDataSource dataSource = JSQLDataSource.newDataSourceBuilder()
.url("jdbcUrl").user("jsql").password("pass").build();
dataSource.transaction(tx -> {
tx.insert("table")
.values(Cond.eq("col1", "val1"), Cond.eq("col2", 102),Cond.eq("col3", "val3"))
.execUpdate();
// if exception thrown will call tx.rollback()
// tx.commit(); // auto commit if transaction ended
});
SQL: insert into table(col1,col2,col3) values(?,?,?)
VALUE: ["val1", 102, "val3"]
Using standalone Transaction to control commit or rollback operation as your favour
JSQLDataSource dataSource = JSQLDataSource.newDataSourceBuilder()
.url("jdbcUrl").user("jsql").password("pass").build();
TransactionDataSource tx = dataSource.transaction();
tx.insert("table")
.values(Cond.eq("col1", "val1"), Cond.eq("col2", 102),Cond.eq("col3", "val3"))
.execUpdate();
tx.close(); // auto commit
SQL: insert into table(col1,col2,col3) values(?,?,?)
VALUE: ["val1", 102, "val3"]
NOTE
Above examples are using JSQLDataSource inner Connection pool to execute SQL generated by JSQL.
Find more documentation here.
- DataSource
- JDBC Connection Pool
- Transaction
- SQL Builder
- Condition
- DB Dialect
- ORM
- SQL Executor
- Logging Customization
performance
- remove Injection's read lock and add snapshot root node for improvement
features
- use builder patterns to create
JSQLDatasource
more easier
others
- update checkstyle version
- simplify Test Unit Exception checking with Lamda
bug fixes
- fix ReentrantLock.lock() prior to try-finally block
- fix bugs which have been detected by FindBugs tools
performance
- optimize scheduled task checking and invalidation
bug fixes
- fix fields injection
performance
- optimize injection checking
- avoid inflating schedule tasks
bug fixes
- fix idle object schedule thread can't shutdown immediately
features
- support validating field name and table name injection
bug fixes
- fix NPE while checking idle object
bug fixes
- fix top-select in
SelectBuilder.select
features
- support transaction in JSQLDataSource
- support
insert... select...
syntax - support Driver properties when getting Connection from Driver
bug fixes
- fix pool configuration
features
- execute builder directly in JSQLDataSource
- refactor Connection object idle timeout validation
jsql-jdk1.6 missing this version
breaks
- Remove
Builder.union
andBuilder.unionAll
operation
bug fixes
- fix
OracleDialect
invalid table alias name format - fix
DB2Dialect
invalid table alias name format
features
- Add builder as Condition value
- Add
UnionSelectBuilder
for union/unionAll operation
jsql-jdk1.6 missing this version