File tree Expand file tree Collapse file tree 5 files changed +34
-16
lines changed
src/main/java/org/nlpcn/jcoder Expand file tree Collapse file tree 5 files changed +34
-16
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ dependencies {
25
25
compile ' org.nutz:nutz:1.r.65'
26
26
compile ' com.alibaba:fastjson:1.2.28'
27
27
compile ' com.h2database:h2:1.3.176'
28
- compile ' com.alibaba:druid:1 .1.9 '
28
+ compile ' com.zaxxer:HikariCP:3 .1.0 '
29
29
compile ' org.quartz-scheduler:quartz:2.2.1'
30
30
compile ' javax.mail:mail:1.4.1'
31
31
compile ' com.google.guava:guava:18.0'
Original file line number Diff line number Diff line change 1
1
package org .nlpcn .jcoder .job ;
2
2
3
- import com .alibaba .druid .util .StringUtils ;
4
3
import com .alibaba .fastjson .JSON ;
5
4
import com .alibaba .fastjson .JSONObject ;
6
5
import com .google .common .base .Strings ;
@@ -119,11 +118,11 @@ public static void add(LogInfo log) {
119
118
if (message .startsWith ("Execute OK" )) {
120
119
// Execute OK ApiTest/test succesed ! use Time : 0
121
120
(stats = new Stats ()).successCount .set (1 );
122
- duration = Integer .parseInt (StringUtils .subString (message , " succesed ! use Time : " , null ).trim ());
121
+ duration = Integer .parseInt (StringUtil .subString (message , " succesed ! use Time : " , null ).trim ());
123
122
} else if (message .startsWith ("Execute ERR" )) {
124
123
// Execute ERR ApiTest/test useTime 0 erred : java.lang.reflect.InvocationTargetException...
125
124
(stats = new Stats ()).errorCount .set (1 );
126
- duration = Integer .parseInt (StringUtils .subString (message , " useTime " , " erred : " ).trim ());
125
+ duration = Integer .parseInt (StringUtil .subString (message , " useTime " , " erred : " ).trim ());
127
126
} else {
128
127
// 忽略其他日志信息
129
128
return ;
Original file line number Diff line number Diff line change 1
1
package org .nlpcn .jcoder .server ;
2
2
3
- import com .alibaba . druid . pool . DruidDataSource ;
3
+ import com .zaxxer . hikari . HikariDataSource ;
4
4
import org .h2 .tools .Server ;
5
5
import org .nlpcn .jcoder .util .IOUtil ;
6
6
import org .nlpcn .jcoder .util .StaticValue ;
@@ -44,15 +44,11 @@ public static void startServer(NutConfig nc) {
44
44
}
45
45
}
46
46
47
- DruidDataSource dds = new DruidDataSource ();
47
+ HikariDataSource dds = new HikariDataSource ();
48
48
dds .setDriverClassName ("org.h2.Driver" );
49
- dds .setUrl ("jdbc:h2:" + h2db );
49
+ dds .setJdbcUrl ("jdbc:h2:" + h2db );
50
50
dds .setUsername ("sa" );
51
51
dds .setPassword ("" );
52
- dds .setInitialSize (10 );
53
- dds .setMaxActive (100 );
54
- dds .setTestOnReturn (true );
55
- dds .setValidationQuery ("select 1" );
56
52
BasicDao basicDao = new BasicDao (dds );
57
53
58
54
StaticValue .systemDao = basicDao ;
Original file line number Diff line number Diff line change @@ -80,4 +80,28 @@ public static String trim(String value) {
80
80
}
81
81
return ((st > 0 ) || (len < value .length ())) ? value .substring (st , len ) : value ;
82
82
}
83
+
84
+
85
+ /**
86
+ * Example: subString("abcd","a","c")="b"
87
+ *
88
+ * @param src
89
+ * @param start null while start from index=0
90
+ * @param to null while to index=src.length
91
+ * @return
92
+ */
93
+ public static String subString (String src , String start , String to ) {
94
+ int indexFrom = start == null ? 0 : src .indexOf (start );
95
+ int indexTo = to == null ? src .length () : src .indexOf (to );
96
+ if (indexFrom < 0 || indexTo < 0 || indexFrom > indexTo ) {
97
+ return null ;
98
+ }
99
+
100
+ if (null != start ) {
101
+ indexFrom += start .length ();
102
+ }
103
+
104
+ return src .substring (indexFrom , indexTo );
105
+
106
+ }
83
107
}
Original file line number Diff line number Diff line change 1
1
package org .nlpcn .jcoder .util .dao ;
2
2
3
- import com .alibaba . druid . pool . DruidDataSource ;
3
+ import com .zaxxer . hikari . HikariDataSource ;
4
4
import org .nutz .castor .Castors ;
5
5
import org .nutz .dao .*;
6
6
import org .nutz .dao .entity .Entity ;
@@ -29,14 +29,13 @@ public class BasicDao {
29
29
30
30
@ Inject
31
31
protected Dao dao ;
32
- private DruidDataSource ds ;
32
+ private HikariDataSource ds ;
33
33
34
34
public BasicDao (String jdbcUrl , String username , String password ) {
35
- ds = new DruidDataSource ();
36
- ds .setUrl (jdbcUrl );
35
+ ds = new HikariDataSource ();
36
+ ds .setJdbcUrl (jdbcUrl );
37
37
ds .setUsername (username );
38
38
ds .setPassword (password );
39
- ds .setMaxWait (60000 );
40
39
this .dao = new NutDao (ds );
41
40
}
42
41
You can’t perform that action at this time.
0 commit comments