mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-09-10 22:19:07 +00:00
实现issue:I7DCQQ支持opengauss类型
This commit is contained in:
@@ -128,6 +128,14 @@ public enum ProductTypeEnum {
|
|||||||
"SELECT 1",
|
"SELECT 1",
|
||||||
"jdbc:sqlite:",
|
"jdbc:sqlite:",
|
||||||
new String[]{"jdbc:sqlite:{file}", "jdbc:sqlite::resource:{file}"}),
|
new String[]{"jdbc:sqlite:{file}", "jdbc:sqlite::resource:{file}"}),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenGauss数据库类型
|
||||||
|
*/
|
||||||
|
OPENGAUSS(14, "\"", "opengauss", "org.opengauss.Driver", 15432,
|
||||||
|
"SELECT 1",
|
||||||
|
"jdbc:opengauss://",
|
||||||
|
new String[]{"jdbc:opengauss://{host}[:{port}]/[{database}][\\?{params}]"}),
|
||||||
;
|
;
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
@@ -176,7 +184,7 @@ public enum ProductTypeEnum {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean isLikePostgres() {
|
public boolean isLikePostgres() {
|
||||||
return this == POSTGRESQL || this == KINGBASE;
|
return this == POSTGRESQL || this == KINGBASE || this == OPENGAUSS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -75,7 +75,14 @@ public final class DatabaseAwareUtils {
|
|||||||
String productName = connection.getMetaData().getDatabaseProductName();
|
String productName = connection.getMetaData().getDatabaseProductName();
|
||||||
String driverName = connection.getMetaData().getDriverName();
|
String driverName = connection.getMetaData().getDriverName();
|
||||||
if (driverNameMap.containsKey(driverName)) {
|
if (driverNameMap.containsKey(driverName)) {
|
||||||
return driverNameMap.get(driverName);
|
ProductTypeEnum productType = driverNameMap.get(driverName);
|
||||||
|
if (productType == ProductTypeEnum.POSTGRESQL) {
|
||||||
|
String url = connection.getMetaData().getURL();
|
||||||
|
if (null != url && url.contains("opengauss")) {
|
||||||
|
return ProductTypeEnum.OPENGAUSS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return productType;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProductTypeEnum type = productNameMap.get(productName);
|
ProductTypeEnum type = productNameMap.get(productName);
|
||||||
|
34
dbswitch-product/dbswitch-product-opengauss/pom.xml
Normal file
34
dbswitch-product/dbswitch-product-opengauss/pom.xml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>dbswitch-product</artifactId>
|
||||||
|
<groupId>com.gitee.dbswitch</groupId>
|
||||||
|
<version>1.8.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>dbswitch-product-openguass</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.gitee.dbswitch</groupId>
|
||||||
|
<artifactId>dbswitch-common</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.gitee.dbswitch</groupId>
|
||||||
|
<artifactId>dbswitch-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.gitee.dbswitch</groupId>
|
||||||
|
<artifactId>dbswitch-product-postgresql</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@@ -0,0 +1,54 @@
|
|||||||
|
// Copyright tang. All rights reserved.
|
||||||
|
// https://gitee.com/inrgihc/dbswitch
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style license
|
||||||
|
//
|
||||||
|
// Author: tang (inrgihc@126.com)
|
||||||
|
// Date : 2020/1/2
|
||||||
|
// Location: beijing , china
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
package com.gitee.dbswitch.product.openguass;
|
||||||
|
|
||||||
|
import com.gitee.dbswitch.annotation.Product;
|
||||||
|
import com.gitee.dbswitch.common.type.ProductTypeEnum;
|
||||||
|
import com.gitee.dbswitch.features.ProductFeatures;
|
||||||
|
import com.gitee.dbswitch.product.postgresql.PostgresTableInsertWriterProvider;
|
||||||
|
import com.gitee.dbswitch.product.postgresql.PostgresTableSynchronizer;
|
||||||
|
import com.gitee.dbswitch.provider.AbstractFactoryProvider;
|
||||||
|
import com.gitee.dbswitch.provider.meta.MetadataProvider;
|
||||||
|
import com.gitee.dbswitch.provider.operate.TableOperateProvider;
|
||||||
|
import com.gitee.dbswitch.provider.sync.TableDataSynchronizer;
|
||||||
|
import com.gitee.dbswitch.provider.write.TableDataWriteProvider;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
@Product(ProductTypeEnum.OPENGAUSS)
|
||||||
|
public class OpenGaussFactoryProvider extends AbstractFactoryProvider {
|
||||||
|
|
||||||
|
public OpenGaussFactoryProvider(DataSource dataSource) {
|
||||||
|
super(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductFeatures getProductFeatures() {
|
||||||
|
return new OpenGaussFeatures();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetadataProvider createMetadataQueryProvider() {
|
||||||
|
return new OpenGaussMetadataQueryProvider(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableOperateProvider createTableOperateProvider() {
|
||||||
|
return new OpenGaussTableOperateProvider(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableDataWriteProvider createTableDataWriteProvider(boolean useInsert) {
|
||||||
|
return new PostgresTableInsertWriterProvider(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableDataSynchronizer createTableDataSynchronizer() {
|
||||||
|
return new PostgresTableSynchronizer(this);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,16 @@
|
|||||||
|
// Copyright tang. All rights reserved.
|
||||||
|
// https://gitee.com/inrgihc/dbswitch
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style license
|
||||||
|
//
|
||||||
|
// Author: tang (inrgihc@126.com)
|
||||||
|
// Date : 2020/1/2
|
||||||
|
// Location: beijing , china
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
package com.gitee.dbswitch.product.openguass;
|
||||||
|
|
||||||
|
import com.gitee.dbswitch.features.ProductFeatures;
|
||||||
|
|
||||||
|
public class OpenGaussFeatures implements ProductFeatures {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,51 @@
|
|||||||
|
// Copyright tang. All rights reserved.
|
||||||
|
// https://gitee.com/inrgihc/dbswitch
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style license
|
||||||
|
//
|
||||||
|
// Author: tang (inrgihc@126.com)
|
||||||
|
// Date : 2020/1/2
|
||||||
|
// Location: beijing , china
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
package com.gitee.dbswitch.product.openguass;
|
||||||
|
|
||||||
|
import com.gitee.dbswitch.product.postgresql.PostgresMetadataQueryProvider;
|
||||||
|
import com.gitee.dbswitch.provider.ProductFactoryProvider;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class OpenGaussMetadataQueryProvider extends PostgresMetadataQueryProvider {
|
||||||
|
|
||||||
|
private static Set<String> systemSchemas = new HashSet<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
systemSchemas.add("blockchain");
|
||||||
|
systemSchemas.add("cstore");
|
||||||
|
systemSchemas.add("db4ai");
|
||||||
|
systemSchemas.add("dbe_perf");
|
||||||
|
systemSchemas.add("dbe_pldebugger");
|
||||||
|
systemSchemas.add("dbe_pldeveloper");
|
||||||
|
systemSchemas.add("dbe_sql_util");
|
||||||
|
systemSchemas.add("information_schema");
|
||||||
|
systemSchemas.add("pg_catalog");
|
||||||
|
systemSchemas.add("pkg_service");
|
||||||
|
systemSchemas.add("snapshot");
|
||||||
|
systemSchemas.add("sqladvisor");
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenGaussMetadataQueryProvider(ProductFactoryProvider factoryProvider) {
|
||||||
|
super(factoryProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> querySchemaList(Connection connection) {
|
||||||
|
List<String> schemas = super.querySchemaList(connection);
|
||||||
|
return schemas.stream()
|
||||||
|
.filter(s -> !systemSchemas.contains(s))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,28 @@
|
|||||||
|
// Copyright tang. All rights reserved.
|
||||||
|
// https://gitee.com/inrgihc/dbswitch
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style license
|
||||||
|
//
|
||||||
|
// Author: tang (inrgihc@126.com)
|
||||||
|
// Date : 2020/1/2
|
||||||
|
// Location: beijing , china
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
package com.gitee.dbswitch.product.openguass;
|
||||||
|
|
||||||
|
import com.gitee.dbswitch.provider.ProductFactoryProvider;
|
||||||
|
import com.gitee.dbswitch.provider.operate.DefaultTableOperateProvider;
|
||||||
|
|
||||||
|
public class OpenGaussTableOperateProvider extends DefaultTableOperateProvider {
|
||||||
|
|
||||||
|
public OpenGaussTableOperateProvider(ProductFactoryProvider factoryProvider) {
|
||||||
|
super(factoryProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dropTable(String schemaName, String tableName) {
|
||||||
|
String sql = String.format("DROP TABLE \"%s\".\"%s\" CASCADE ",
|
||||||
|
schemaName, tableName);
|
||||||
|
this.executeSql(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1 @@
|
|||||||
|
com.gitee.dbswitch.product.openguass.OpenGaussFactoryProvider
|
@@ -78,6 +78,11 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 新增加的数据库产品需要在这里追加依赖-->
|
<!-- 新增加的数据库产品需要在这里追加依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.gitee.dbswitch</groupId>
|
||||||
|
<artifactId>dbswitch-product-openguass</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
@@ -25,6 +25,7 @@
|
|||||||
<module>dbswitch-product-mariadb</module>
|
<module>dbswitch-product-mariadb</module>
|
||||||
<module>dbswitch-product-hive</module>
|
<module>dbswitch-product-hive</module>
|
||||||
<module>dbswitch-product-gbase</module>
|
<module>dbswitch-product-gbase</module>
|
||||||
|
<module>dbswitch-product-opengauss</module>
|
||||||
<module>dbswitch-register-product</module>
|
<module>dbswitch-register-product</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
BIN
drivers/opengauss/opengauss-3.0.0/opengauss-jdbc-3.0.0.jar
Normal file
BIN
drivers/opengauss/opengauss-3.0.0/opengauss-jdbc-3.0.0.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user