mirror of
https://github.com/WeiYe-Jing/datax-web.git
synced 2026-06-13 21:00:50 +08:00
commit
3ea9a5b07d
@ -788,6 +788,12 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.ibm.db2.jcc/db2jcc -->
|
||||
<dependency>
|
||||
<groupId>com.ibm.db2.jcc</groupId>
|
||||
<artifactId>db2jcc</artifactId>
|
||||
<version>db2jcc4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -127,6 +127,9 @@ public class DataxJsonHelper implements DataxJsonInterface {
|
||||
} else if (MONGODB.equals(datasource)) {
|
||||
readerPlugin = new MongoDBReader();
|
||||
buildReader = buildMongoDBReader();
|
||||
} else if (DB2.equals(datasource)) {
|
||||
readerPlugin = new DB2Reader();
|
||||
buildReader = buildReader();
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,6 +168,9 @@ public class DataxJsonHelper implements DataxJsonInterface {
|
||||
} else if (JdbcConstants.MONGODB.equals(datasource)) {
|
||||
writerPlugin = new MongoDBWriter();
|
||||
buildWriter = this.buildMongoDBWriter();
|
||||
}else if (DB2.equals(datasource)) {
|
||||
writerPlugin = new DB2Writer();
|
||||
buildWriter = this.buildWriter();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package com.wugui.datax.admin.tool.datax.reader;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* db2 reader 构建类
|
||||
*
|
||||
* @author Locki
|
||||
* @version 1.0
|
||||
* @since 2020-09-12 16:18:17
|
||||
*/
|
||||
public class DB2Reader extends BaseReaderPlugin implements DataxReaderInterface {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "db2reader";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> sample() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.wugui.datax.admin.tool.datax.writer;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* db2 writer构建类
|
||||
*
|
||||
* @author Locki
|
||||
* @version 1.0
|
||||
* @since 2020-09-12 16:18:17
|
||||
*/
|
||||
public class DB2Writer extends BaseWriterPlugin implements DataxWriterInterface {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "db2writer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> sample() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package com.wugui.datax.admin.tool.meta;
|
||||
|
||||
/**
|
||||
* DB2数据库meta信息查询
|
||||
*
|
||||
* @author Locki
|
||||
* @date 2020/9/12
|
||||
*/
|
||||
public class DB2DatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface {
|
||||
private volatile static DB2DatabaseMeta single;
|
||||
|
||||
public static DB2DatabaseMeta getInstance() {
|
||||
if (single == null) {
|
||||
synchronized (DB2DatabaseMeta.class) {
|
||||
if (single == null) {
|
||||
single = new DB2DatabaseMeta();
|
||||
}
|
||||
}
|
||||
}
|
||||
return single;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLQueryTablesNameComments() {
|
||||
return "SELECT TABNAME, REMARKS FROM SYSCAT.TABLES WHERE TABSCHEMA = ?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLQueryTableNameComment() {
|
||||
return "SELECT TABNAME, REMARKS FROM SYSCAT.TABLES WHERE TABSCHEMA = ? AND TABNAME = ?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLQueryPrimaryKey() {
|
||||
return "SELECT COLNAME FROM SYSCAT.KEYCOLUSE WHERE TABSCHEMA = ? AND TABNAME = ?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLQueryComment(String schemaName, String tableName, String columnName) {
|
||||
return String.format("SELECT REMARKS FROM SYSCAT.COLUMNS WHERE TABSCHEMA = '%s' AND TABNAME = '%s' AND COLNAME = '%s'", schemaName, tableName, columnName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLQueryColumns(String... args) {
|
||||
return "SELECT COLNAME FROM SYSCAT.COLUMNS WHERE TABSCHEMA = ? AND TABNAME = ?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLQueryTableSchema(String... args) {
|
||||
return "SELECT SCHEMANAME FROM SYSCAT.SCHEMATA WHERE OWNERTYPE = 'U'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLQueryTables() {
|
||||
return "SELECT TABNAME, REMARKS FROM SYSCAT.TABLES WHERE TABSCHEMA = CURRENT SCHEMA";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLQueryTables(String... tableSchema) {
|
||||
return String.format("SELECT TABNAME, REMARKS FROM SYSCAT.TABLES WHERE TABSCHEMA = '%s'", tableSchema[0]);
|
||||
}
|
||||
}
|
||||
@ -28,6 +28,8 @@ public class DatabaseMetaFactory {
|
||||
return ClickHouseDataBaseMeta.getInstance();
|
||||
} else if(JdbcConstants.HBASE20XSQL.equals(dbType)) {
|
||||
return Hbase20xsqlMeta.getInstance();
|
||||
} else if(JdbcConstants.DB2.equals(dbType)) {
|
||||
return DB2DatabaseMeta.getInstance();
|
||||
} else {
|
||||
throw new UnsupportedOperationException("暂不支持的类型:".concat(dbType));
|
||||
}
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.wugui.datax.admin.tool.query;
|
||||
|
||||
import com.wugui.datax.admin.entity.JobDatasource;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* DB2数据库使用的查询工具
|
||||
*
|
||||
* @author Locki
|
||||
* @ClassName DB2SQLQueryTool
|
||||
* @Version 1.0
|
||||
* @since 2020-09-12 16:18:17
|
||||
*/
|
||||
public class DB2SQLQueryTool extends BaseQueryTool implements QueryToolInterface {
|
||||
|
||||
public DB2SQLQueryTool(JobDatasource jobDatasource) throws SQLException {
|
||||
super(jobDatasource);
|
||||
}
|
||||
|
||||
}
|
||||
@ -33,6 +33,8 @@ public class QueryToolFactory {
|
||||
return getClickHouseQueryToolInstance(jobDatasource);
|
||||
}else if (JdbcConstants.HBASE20XSQL.equals(datasource)) {
|
||||
return getHbase20XsqlQueryToolQueryToolInstance(jobDatasource);
|
||||
}else if (JdbcConstants.DB2.equals(datasource)) {
|
||||
return getDB2QueryToolInstance(jobDatasource);
|
||||
}
|
||||
throw new UnsupportedOperationException("找不到该类型: ".concat(datasource));
|
||||
}
|
||||
@ -98,4 +100,13 @@ public class QueryToolFactory {
|
||||
e, jdbcDatasource.getJdbcUsername(), jdbcDatasource.getDatasourceName());
|
||||
}
|
||||
}
|
||||
|
||||
private static BaseQueryTool getDB2QueryToolInstance(JobDatasource jdbcDatasource) {
|
||||
try {
|
||||
return new DB2SQLQueryTool(jdbcDatasource);
|
||||
} catch (SQLException e) {
|
||||
throw RdbmsException.asConnException(JdbcConstants.DB2,
|
||||
e, jdbcDatasource.getJdbcUsername(), jdbcDatasource.getDatasourceName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ logging:
|
||||
#path: ./data/applogs/admin
|
||||
level:
|
||||
com.wugui.datax.admin.mapper: error
|
||||
path: ${data.path}/applogs/admin
|
||||
path: ${data.path}/applogs/admin
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user