Skip to content

Commit 02e8018

Browse files
wizzerwizzer
authored andcommitted
add: 崖山数据库支持
1 parent c425ef4 commit 02e8018

File tree

7 files changed

+375
-4
lines changed

7 files changed

+375
-4
lines changed

pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>nutz</artifactId>
66
<packaging>jar</packaging>
77
<name>Nutz</name>
8-
<version>1.r.73-SNAPSHOT</version>
8+
<version>1.r.74-SNAPSHOT</version>
99
<properties>
1010
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1111
<jetty.version>9.4.34.v20201102</jetty.version>
@@ -103,10 +103,16 @@
103103
<version>3.4.1</version>
104104
<scope>test</scope>
105105
</dependency>
106+
<dependency>
107+
<groupId>com.yashandb</groupId>
108+
<artifactId>yashandb-jdbc</artifactId>
109+
<version>1.7.10</version>
110+
<scope>test</scope>
111+
</dependency>
106112
<dependency>
107113
<groupId>com.alibaba</groupId>
108114
<artifactId>druid</artifactId>
109-
<version>1.1.22</version>
115+
<version>1.2.25</version>
110116
<scope>test</scope>
111117
<exclusions>
112118
<exclusion>

src/org/nutz/dao/DB.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public enum DB {
5959
* DM_MYSQL
6060
*/
6161
DM_MYSQL,
62+
/**
63+
* YashanDB
64+
*/
65+
YASHAN,
6266
/**
6367
* TDengine
6468
*/

src/org/nutz/dao/DatabaseMeta.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public void setProductName(String productName) {
6565
type = DB.DM;
6666
} else if (proName.contains("dm mysql")) {
6767
type = DB.DM_MYSQL;
68+
} else if (proName.contains("yashandb")) {
69+
type = DB.YASHAN;
6870
} else if (proName.contains("tdengine")) {
6971
type = DB.TDENGINE;
7072
} else {
@@ -165,8 +167,12 @@ public boolean isHsql() {
165167
public boolean isDerby() {
166168
return DB.DERBY == type;
167169
}
168-
170+
169171
public boolean isDm() {
170172
return DB.DM == type;
171173
}
174+
175+
public boolean isYashan() {
176+
return DB.YASHAN == type;
177+
}
172178
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.nutz.dao.impl.jdbc.yashan;
2+
3+
import org.nutz.dao.jdbc.ValueAdaptor;
4+
5+
import java.sql.PreparedStatement;
6+
import java.sql.ResultSet;
7+
import java.sql.SQLException;
8+
import java.sql.Types;
9+
10+
/**
11+
* 对 Oracle,Types.BOOLEAN 对于 setNull 是不工作的 其他的数据库都没有这个问题,<br>
12+
* 所以,只好把类型设成 INTEGER了
13+
*/
14+
public class YashanBooleanAdaptor implements ValueAdaptor {
15+
16+
public Object get(ResultSet rs, String colName) throws SQLException {
17+
boolean re = rs.getBoolean(colName);
18+
return rs.wasNull() ? null : re;
19+
}
20+
21+
public void set(PreparedStatement stat, Object obj, int i) throws SQLException {
22+
if (null == obj) {
23+
stat.setNull(i, Types.BOOLEAN);
24+
} else {
25+
boolean v;
26+
if (obj instanceof Boolean)
27+
v = (Boolean) obj;
28+
else if (obj instanceof Number)
29+
v = ((Number) obj).intValue() > 0;
30+
else if (obj instanceof Character)
31+
v = Character.toUpperCase((Character) obj) == 'T';
32+
else
33+
v = Boolean.valueOf(obj.toString());
34+
stat.setBoolean(i, v);
35+
}
36+
}
37+
38+
}

0 commit comments

Comments
 (0)