Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Commit

Permalink
Merge pull request #11 from lets-blade/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
hellokaton authored Nov 10, 2017
2 parents 07db691 + bf59670 commit cd55f0a
Show file tree
Hide file tree
Showing 15 changed files with 380 additions and 216 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ language: java
jdk:
- oraclejdk8
script:
- mvn install -Dmaven.test.skip=true
- mvn compile -Dmaven.test.skip=true

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

## 更新日志

### v0.2.2

1. 修复 `in` 查询问题
2. 添加单条自定义类型查询
3. 添加查询自定义类型列表
4. SQL关键词大写

### v0.2.0

1. 使用Java8重构
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.bladejava</groupId>
<artifactId>blade-jdbc</artifactId>
<version>0.2.2-alpha1</version>
<version>0.2.2-RELEASE</version>
<packaging>jar</packaging>

<name>blade-jdbc</name>
Expand Down Expand Up @@ -53,8 +53,8 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
<scope>compile</scope>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>

<dependency>
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/com/blade/jdbc/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ public final class Base {

public static Sql2o open(String url, String user, String password) {
sql2o = new Sql2o(url, user, password);
log.info("⬢ Blade-JDBC initializing");
return sql2o;
}

public static Sql2o open(DataSource dataSource) {
sql2o = new Sql2o(dataSource);
log.info("⬢ Blade-JDBC initializing");
return sql2o;
}

public static Sql2o open(Sql2o sql2o_) {
sql2o = sql2o_;
log.info("⬢ Blade-JDBC initializing");
return sql2o;
}

Expand All @@ -35,14 +43,12 @@ public static Sql2o open(DataSource dataSource) {
public static <T> T atomic(Supplier<T> supplier) {
T result = null;
try {
connectionThreadLocal.remove();
connectionThreadLocal.set(sql2o.beginTransaction());
try (Connection con = connectionThreadLocal.get()) {
result = supplier.get();
con.commit();
}
Connection connection = sql2o.beginTransaction();
connectionThreadLocal.set(connection);
result = supplier.get();
connection.commit();
} catch (RuntimeException e) {
log.info("Transaction rollback");
log.warn("Transaction rollback");
connectionThreadLocal.get().rollback();
throw e;
} finally {
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/blade/jdbc/Const.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.blade.jdbc;

/**
* Blade JDBC Const
*
* @author biezhi
* @date 2017/11/10
*/
public interface Const {

String SPACE = " ";
String SQL_AND = "AND";
String SQL_OR = "OR";
String SQL_WHERE = "WHERE";
String SQL_IN = "IN";
String SQL_INSERT = "INSERT INTO";

String SQL_QM = "?";
String EXECUTE_SQL_PREFIX = "⬢ Execute SQL";
String PARAMETER_PREFIX = "⬢ Parameters ";

char IN_START = '(';
char IN_END = ')';

}
Loading

0 comments on commit cd55f0a

Please sign in to comment.