Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
njgzx
dataease
Commits
bc1462c4
提交
bc1462c4
authored
9月 29, 2021
作者:
taojinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 【数据源】用户可以通过JDBC连接字符串的配置连接到任意支持JDBC的数据库
上级
814aee0e
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
107 行增加
和
40 行删除
+107
-40
CHConfigration.java
.../main/java/io/dataease/datasource/dto/CHConfigration.java
+16
-5
MysqlConfigration.java
...in/java/io/dataease/datasource/dto/MysqlConfigration.java
+15
-5
PgConfigration.java
.../main/java/io/dataease/datasource/dto/PgConfigration.java
+16
-6
SqlServerConfigration.java
...ava/io/dataease/datasource/dto/SqlServerConfigration.java
+14
-5
DatasourceService.java
...ava/io/dataease/datasource/service/DatasourceService.java
+28
-9
en.js
frontend/src/lang/en.js
+2
-1
tw.js
frontend/src/lang/tw.js
+2
-1
zh.js
frontend/src/lang/zh.js
+2
-1
form.vue
frontend/src/views/system/datasource/form.vue
+12
-7
没有找到文件。
backend/src/main/java/io/dataease/datasource/dto/CHConfigration.java
浏览文件 @
bc1462c4
...
...
@@ -2,18 +2,28 @@ package io.dataease.datasource.dto;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.apache.commons.lang3.StringUtils
;
@Getter
@Setter
public
class
CHConfigration
extends
JdbcDTO
{
private
String
driver
=
"ru.yandex.clickhouse.ClickHouseDriver"
;
private
String
extraParams
=
""
;
public
String
getJdbc
()
{
// 连接参数先写死,后边要把编码、时区等参数放到数据源的设置中
return
"jdbc:clickhouse://HOSTNAME:PORT/DATABASE"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
());
if
(
StringUtils
.
isEmpty
(
extraParams
.
trim
())){
return
"jdbc:clickhouse://HOSTNAME:PORT/DATABASE"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
());
}
else
{
return
"jdbc:clickhouse://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
())
.
replace
(
"EXTRA_PARAMS"
,
getExtraParams
().
trim
());
}
}
}
\ No newline at end of file
backend/src/main/java/io/dataease/datasource/dto/MysqlConfigration.java
浏览文件 @
bc1462c4
...
...
@@ -2,18 +2,27 @@ package io.dataease.datasource.dto;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.apache.commons.lang3.StringUtils
;
@Getter
@Setter
public
class
MysqlConfigration
extends
JdbcDTO
{
private
String
driver
=
"com.mysql.cj.jdbc.Driver"
;
private
String
extraParams
=
"characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true"
;
public
String
getJdbc
()
{
// 连接参数先写死,后边要把编码、时区等参数放到数据源的设置中
return
"jdbc:mysql://HOSTNAME:PORT/DATABASE?characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
());
if
(
StringUtils
.
isEmpty
(
extraParams
.
trim
())){
return
"jdbc:mysql://HOSTNAME:PORT/DATABASE"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
());
}
else
{
return
"jdbc:mysql://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
())
.
replace
(
"EXTRA_PARAMS"
,
getExtraParams
().
trim
());
}
}
}
\ No newline at end of file
backend/src/main/java/io/dataease/datasource/dto/PgConfigration.java
浏览文件 @
bc1462c4
...
...
@@ -2,18 +2,27 @@ package io.dataease.datasource.dto;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.apache.commons.lang3.StringUtils
;
@Getter
@Setter
public
class
PgConfigration
extends
JdbcDTO
{
private
String
driver
=
"org.postgresql.Driver"
;
private
String
extraParams
=
""
;
public
String
getJdbc
()
{
// 连接参数先写死,后边要把编码、时区等参数放到数据源的设置中
return
"jdbc:postgresql://HOSTNAME:PORT/DATABASE"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
());
if
(
StringUtils
.
isEmpty
(
extraParams
.
trim
())){
return
"jdbc:postgresql://HOSTNAME:PORT/DATABASE"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
());
}
else
{
return
"jdbc:postgresql://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
())
.
replace
(
"EXTRA_PARAMS"
,
getExtraParams
().
trim
());
}
}
}
\ No newline at end of file
backend/src/main/java/io/dataease/datasource/dto/SqlServerConfigration.java
浏览文件 @
bc1462c4
...
...
@@ -2,17 +2,26 @@ package io.dataease.datasource.dto;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.apache.commons.lang3.StringUtils
;
@Getter
@Setter
public
class
SqlServerConfigration
extends
JdbcDTO
{
private
String
driver
=
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
;
private
String
extraParams
=
""
;
public
String
getJdbc
(){
return
"jdbc:sqlserver://HOSTNAME:PORT;DatabaseName=DATABASE"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
());
if
(
StringUtils
.
isEmpty
(
extraParams
.
trim
())){
return
"jdbc:sqlserver://HOSTNAME:PORT;DatabaseName=DATABASE"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
());
}
else
{
return
"jdbc:sqlserver://HOSTNAME:PORT;DatabaseName=DATABASE;EXTRA_PARAMS"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
())
.
replace
(
"EXTRA_PARAMS"
,
getExtraParams
().
trim
());
}
}
}
backend/src/main/java/io/dataease/datasource/service/DatasourceService.java
浏览文件 @
bc1462c4
...
...
@@ -15,9 +15,8 @@ import io.dataease.controller.ResultHolder;
import
io.dataease.controller.request.DatasourceUnionRequest
;
import
io.dataease.controller.sys.base.BaseGridRequest
;
import
io.dataease.controller.sys.base.ConditionEntity
;
import
io.dataease.datasource.dto.DBTableDTO
;
import
io.dataease.datasource.dto.MysqlConfigration
;
import
io.dataease.datasource.dto.OracleConfigration
;
import
io.dataease.datasource.constants.DatasourceTypes
;
import
io.dataease.datasource.dto.*
;
import
io.dataease.datasource.provider.DatasourceProvider
;
import
io.dataease.datasource.provider.ProviderFactory
;
import
io.dataease.datasource.request.DatasourceRequest
;
...
...
@@ -90,12 +89,32 @@ public class DatasourceService {
request
.
setSort
(
"update_time desc"
);
List
<
DatasourceDTO
>
datasourceDTOS
=
extDataSourceMapper
.
queryUnion
(
request
);
datasourceDTOS
.
forEach
(
datasourceDTO
->
{
if
(
datasourceDTO
.
getType
().
equalsIgnoreCase
(
"mysql"
)){
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
MysqlConfigration
.
class
))
);
};
if
(
datasourceDTO
.
getType
().
equalsIgnoreCase
(
"oracle"
)){
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
OracleConfigration
.
class
)));
};
DatasourceTypes
datasourceType
=
DatasourceTypes
.
valueOf
(
datasourceDTO
.
getType
());
try
{
switch
(
datasourceType
)
{
case
mysql:
case
mariadb:
case
de_doris:
case
ds_doris:
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
MysqlConfigration
.
class
))
);
break
;
case
sqlServer:
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
SqlServerConfigration
.
class
))
);
break
;
case
oracle:
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
OracleConfigration
.
class
))
);
break
;
case
pg:
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
PgConfigration
.
class
))
);
break
;
case
ck:
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
CHConfigration
.
class
))
);
break
;
default
:
break
;
}
}
catch
(
Exception
ignore
){}
});
return
datasourceDTOS
;
}
...
...
frontend/src/lang/en.js
浏览文件 @
bc1462c4
...
...
@@ -1150,7 +1150,8 @@ export default {
please_input_acquire_increment
:
'Please enter the growth number'
,
please_input_connect_timeout
:
'Please enter the connection timeout (seconds)'
,
no_less_then_0
:
'Parameters in advanced settings cannot be less than zero'
,
priority
:
'Advanced setting'
priority
:
'Advanced setting'
,
extra_params
:
'Extra JDBC connection string'
},
pblink
:
{
key_pwd
:
'Please enter the password to open the link'
,
...
...
frontend/src/lang/tw.js
浏览文件 @
bc1462c4
...
...
@@ -1153,7 +1153,8 @@ export default {
please_input_acquire_increment
:
'請輸入增長數'
,
please_input_connect_timeout
:
'請輸入連接超時(秒)'
,
no_less_then_0
:
'高級設置中的參數不能小于零'
,
priority
:
'高級設置'
priority
:
'高級設置'
,
extra_params
:
'額外的JDBC連接字符串'
},
pblink
:
{
key_pwd
:
'請輸入密碼打開鏈接'
,
...
...
frontend/src/lang/zh.js
浏览文件 @
bc1462c4
...
...
@@ -1158,7 +1158,8 @@ export default {
data_mode
:
'数据模式'
,
direct
:
'直连模式'
,
extract
:
'抽取模式'
,
all_compute_mode
:
'直连、抽取模式'
all_compute_mode
:
'直连、抽取模式'
,
extra_params
:
'额外的JDBC连接字符串'
},
pblink
:
{
key_pwd
:
'请输入密码打开链接'
,
...
...
frontend/src/views/system/datasource/form.vue
浏览文件 @
bc1462c4
...
...
@@ -52,6 +52,10 @@
<el-input
v-model=
"form.configuration.esPassword"
autocomplete=
"off"
show-password
/>
</el-form-item>
<el-form-item
v-if=
"form.configuration.dataSourceType=='jdbc' && form.type!=='oracle'"
:label=
"$t('datasource.extra_params')"
>
<el-input
v-model=
"form.configuration.extraParams"
autocomplete=
"off"
/>
</el-form-item>
<el-form-item
v-if=
"form.configuration.dataSourceType=='jdbc'"
:label=
"$t('datasource.port')"
prop=
"configuration.port"
>
<el-input
v-model=
"form.configuration.port"
autocomplete=
"off"
/>
</el-form-item>
...
...
@@ -155,14 +159,14 @@ export default {
'configuration.connectTimeout'
:
[{
required
:
true
,
message
:
this
.
$t
(
'datasource.please_input_connect_timeout'
),
trigger
:
'change'
}]
},
allTypes
:
[
{
name
:
'mysql'
,
label
:
'MySQL'
,
type
:
'jdbc'
},
{
name
:
'oracle'
,
label
:
'Oracle'
,
type
:
'jdbc'
},
{
name
:
'sqlServer'
,
label
:
'SQL Server'
,
type
:
'jdbc'
},
{
name
:
'pg'
,
label
:
'PostgreSQL'
,
type
:
'jdbc'
},
{
name
:
'mysql'
,
label
:
'MySQL'
,
type
:
'jdbc'
,
extraParams
:
'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
},
{
name
:
'oracle'
,
label
:
'Oracle'
,
type
:
'jdbc'
},
{
name
:
'sqlServer'
,
label
:
'SQL Server'
,
type
:
'jdbc'
,
extraParams
:
''
},
{
name
:
'pg'
,
label
:
'PostgreSQL'
,
type
:
'jdbc'
,
extraParams
:
''
},
{
name
:
'es'
,
label
:
'Elasticsearch'
,
type
:
'es'
},
{
name
:
'mariadb'
,
label
:
'MariaDB'
,
type
:
'jdbc'
},
{
name
:
'ds_doris'
,
label
:
'Doris'
,
type
:
'jdbc'
},
{
name
:
'ck'
,
label
:
'ClickHouse'
,
type
:
'jdbc'
}
{
name
:
'mariadb'
,
label
:
'MariaDB'
,
type
:
'jdbc'
,
extraParams
:
'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
},
{
name
:
'ds_doris'
,
label
:
'Doris'
,
type
:
'jdbc'
,
extraParams
:
'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
},
{
name
:
'ck'
,
label
:
'ClickHouse'
,
type
:
'jdbc'
,
extraParams
:
''
}
],
schemas
:
[],
canEdit
:
false
,
...
...
@@ -303,6 +307,7 @@ export default {
for
(
let
i
=
0
;
i
<
this
.
allTypes
.
length
;
i
++
)
{
if
(
this
.
allTypes
[
i
].
name
===
this
.
form
.
type
)
{
this
.
form
.
configuration
.
dataSourceType
=
this
.
allTypes
[
i
].
type
this
.
form
.
configuration
.
extraParams
=
this
.
allTypes
[
i
].
extraParams
}
}
},
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论