Hi,
Actually, we need to communicate in English. Otherwise, i can not confirm the 
validity of this configuration , for it is presented in plain format in this 
email. So my suggestion is to compare it with those configurations in our 
example project[1].


[1] https://github.com/apache/incubator-shardingsphere-doc


Regards,
Trista


 Juan Pan


[email protected]
Juan Pan(Trista), Apache ShardingSphere


??2019??09??25?? 15:07????????????<[email protected]> ??????
??????
????????sharding-jdbc????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?? ??2??????????????Postgresql????
dsjava??dsc
??????????????????java??c
----------------------------------------
?? ????????????2??????
t_staff_male, t_staff_female
????????????????????????
-------------------------------------------
?? ????????????
DROP TABLE "public"."t_staff_male";
CREATE TABLE "public"."t_staff_male" (
"staff_id" varchar(10) NOT NULL,
"staff_name" varchar(16) NOT NULL,
"staff_sex" varchar(8) NOT NULL,
"group_code" varchar(8),
"id_number_plain" varchar(32),
"id_number_cipher" varchar(64)
)
WITH (OIDS=FALSE)
;

ALTER TABLE "public"."t_staff_male" ADD PRIMARY KEY ("staff_id");
--------------------------------------------------------------------------------------
?? ??Springboot2.1.*+Mybatis3.5.* ??????????application.yml????
mybatis:
config-location: classpath:META-INF/mybatis-config.xml
mapper-locations: classpath:com/example/shardingsphere/dao/mappers/*.xml

spring:
shardingsphere:
datasource:
names:  dsjava,dsc
dsjava:
type: org.apache.commons.dbcp2.BasicDataSource
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://127.0.0.1:5444/dsjava
username: fan
password:
dsc:
type: org.apache.commons.dbcp2.BasicDataSource
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://127.0.0.1:5444/dsc
username: fan
password:
sharding:
default-database-strategy:
inline:
sharding-column: group_code
algorithm-expression: ds$-&gt;{group_code}
tables:
t_staff:
actual-data-nodes: ds$-&gt;{['java', 'c']}.t_staff_$-&gt;{['male', 'female']}
table-strategy:
inline:
sharding-column: staff_sex
algorithm-expression: t_staff_$-&gt;{staff_sex}
encrypt:
encryptors:
encryptor_aes:
type: aes
props:
aes.key.value: 123456
tables:
t_staff:
columns:
id_number:
plainColumn: id_number_plain
cipherColumn: id_number_cipher
encryptor: encryptor_aes
props:
sql.show: true
query.with.cipher.comlum: true 
---------------------------------------------------------------------------- ?? 
??StaffMapper.xml <insert id="save" parameterType="staff"&gt;
insert into t_staff
<trim prefix="(" suffix=")" suffixOverrides="," &gt;
<if test="staffId != null" &gt;
staff_id,
</if&gt;
<if test="staffName != null" &gt;
staff_name,
</if&gt;
<if test="staffSex != null" &gt;
staff_sex,
</if&gt;
<if test="groupCode != null" &gt;
group_code,
</if&gt;
<if test="idNumber != null" &gt;
id_number,
</if&gt;
</trim&gt;
<trim prefix="values (" suffix=")" suffixOverrides="," &gt;
<if test="staffId != null" &gt;
#{staffId},
</if&gt;
<if test="staffName != null" &gt;
#{staffName},
</if&gt;
<if test="staffSex != null" &gt;
#{staffSex},
</if&gt;
<if test="groupCode != null" &gt;
#{groupCode},
</if&gt;
<if test="idNumber != null" &gt;
#{idNumber},
</if&gt;
</trim&gt;
</insert&gt; 
---------------------------------------------------------------------- ?? 
?????????? 
1????????application.yml????????????????????????????????????t_staff??????????????????????????????????????
 2?????????????????????????????? ### Error updating database.&nbsp; Cause: 
org.postgresql.util.PSQLException: ????: ???? "t_staff" ??????
&nbsp; ??????13
### The error may exist in file 
[D:\idea_workspace\sharding-sphere\target\classes\com\example\shardingsphere\dao\mappers\StaffMapper.xml]
### The error may involve com.example.shardingsphere.dao.StaffMapper.save-Inline
### The error occurred while setting parameters
### SQL: insert into t_staff( staff_id, staff_name, staff_sex, group_code, 
id_number ) values (?, ?, ?, ?, ? )
### Cause: org.postgresql.util.PSQLException: ????: ???? "t_staff" ?????? 
??????13; bad SQL grammar []; nested exception is 
org.postgresql.util.PSQLException: ????: ???? "t_staff" ?????? ??????13] with 
root cause ??????????????????????????????????

Reply via email to