diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-all/pom.xml b/datavines-connector/datavines-connector-plugins/datavines-connector-all/pom.xml index d3ba62d2e002e61d308e3058cac2058dfedace03..1f0bb8067274c42441e9250b5d45dba2f40c85ef 100644 --- a/datavines-connector/datavines-connector-plugins/datavines-connector-all/pom.xml +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-all/pom.xml @@ -36,6 +36,12 @@ ${project.version} + + io.datavines + datavines-connector-mariadb + ${project.version} + + io.datavines datavines-connector-hive diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/pom.xml b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..a5b104c1e3e261008f9e62a8b702997f083c1047 --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/pom.xml @@ -0,0 +1,42 @@ + + + + + + datavines-connector-plugins + io.datavines + 1.0.0-SNAPSHOT + + 4.0.0 + + datavines-connector-mariadb + + + + io.datavines + datavines-connector-jdbc + ${project.version} + + + + + \ No newline at end of file diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConfigBuilder.java b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConfigBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..355290de22882ce4efb17c6a0d4e120f56d8f0fa --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConfigBuilder.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.connector.plugin; + +import io.datavines.common.param.form.type.InputParam; + +public class MariadbConfigBuilder extends JdbcConfigBuilder { + + @Override + protected InputParam getPropertiesInput(boolean isEn) { + return getInputParam("properties", + isEn ? "properties" : "参数", + isEn ? "please enter properties,like key=value&key1=value1" : "请填入参数,格式为key=value&key1=value1", 2, null, + "useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useInformationSchema=true"); + } + + @Override + protected InputParam getDatabaseInput(boolean isEn) { + return getInputParam("database", + isEn ? "database" : "数据库", + isEn ? "please enter database" : "请填入数据库", 1, null, + null); + } +} diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConnector.java b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConnector.java new file mode 100644 index 0000000000000000000000000000000000000000..bc58961c9ac9492cbc35d75b578047d8b983e932 --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConnector.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.connector.plugin; + +import io.datavines.common.datasource.jdbc.BaseJdbcDataSourceInfo; +import io.datavines.common.datasource.jdbc.JdbcConnectionInfo; +import io.datavines.connector.api.DataSourceClient; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class MariadbConnector extends JdbcConnector { + + public MariadbConnector(DataSourceClient dataSourceClient) { + super(dataSourceClient); + } + @Override + public BaseJdbcDataSourceInfo getDatasourceInfo(JdbcConnectionInfo jdbcConnectionInfo) { + return new MariadbDataSourceInfo(jdbcConnectionInfo); + } + + @Override + public ResultSet getMetadataDatabases(Connection connection) throws SQLException { + DatabaseMetaData metaData = connection.getMetaData(); + return metaData.getCatalogs(); + } + +} diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConnectorFactory.java b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConnectorFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..0c893e8449397fa0fd46d8146a721c0c6e0ab9e7 --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConnectorFactory.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.connector.plugin; + +import io.datavines.connector.api.*; + +public class MariadbConnectorFactory extends AbstractJdbcConnectorFactory { + + @Override + public ConnectorParameterConverter getConnectorParameterConverter() { + return new MariadbConnectorParameterConverter(); + } + + @Override + public Dialect getDialect() { + return new MariadbDialect(); + } + + @Override + public Connector getConnector() { + return new MariadbConnector(getDataSourceClient()); + } + + @Override + public Executor getExecutor() { + return new MariadbExecutor(getDataSourceClient()); + } + + @Override + public ConfigBuilder getConfigBuilder() { + return new MariadbConfigBuilder(); + } +} diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConnectorParameterConverter.java b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConnectorParameterConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..68c84725577b9fbcb9fb8d02b74bc814d0373a31 --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbConnectorParameterConverter.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.connector.plugin; + +import java.util.Map; + +import io.datavines.common.utils.StringUtils; +import static io.datavines.common.ConfigConstants.*; + +public class MariadbConnectorParameterConverter extends JdbcConnectorParameterConverter { + + @Override + protected String getUrl(Map parameter) { + String url = String.format("jdbc:mariadb://%s:%s/%s", + parameter.get(HOST), + parameter.get(PORT), + parameter.get(DATABASE)); + String properties = (String)parameter.get(PROPERTIES); + if (StringUtils.isNotEmpty(properties)) { + url += "?" + properties; + } + + return url; + } + +} diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbDataSourceInfo.java b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbDataSourceInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..1de6187a10d8cee53fdc1eda5ca2773b2a823691 --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbDataSourceInfo.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.connector.plugin; + +import io.datavines.common.datasource.jdbc.BaseJdbcDataSourceInfo; +import io.datavines.common.datasource.jdbc.JdbcConnectionInfo; + +public class MariadbDataSourceInfo extends BaseJdbcDataSourceInfo { + + public MariadbDataSourceInfo(JdbcConnectionInfo jdbcConnectionInfo) { + super(jdbcConnectionInfo); + } + + @Override + public String getAddress() { + return "jdbc:mariadb://"+getHost()+":"+getPort(); + } + + @Override + public String getDriverClass() { + return "org.mariadb.jdbc.Driver"; + } + + @Override + public String getType() { + return "mariadb"; + } + + @Override + protected String getSeparator() { + return "?"; + } + + @Override + protected String filterProperties(String other){ + return other; + } +} diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbDialect.java b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbDialect.java new file mode 100644 index 0000000000000000000000000000000000000000..96644072b1063cd39ca891bb17b5a120fb0f8e2a --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbDialect.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.connector.plugin; + +import java.util.Map; + +import static io.datavines.common.ConfigConstants.STRING_TYPE; + +public class MariadbDialect extends JdbcDialect { + + @Override + public Map getDialectKeyMap() { + super.getDialectKeyMap(); + dialectKeyMap.put(STRING_TYPE, "char"); + return dialectKeyMap; + } + + @Override + public String getDriver() { + return "org.mariadb.jdbc.Driver"; + } + + @Override + public boolean invalidateItemCanOutputToSelf() { + return true; + } + + @Override + public boolean supportToBeErrorDataStorage() { + return true; + } +} diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbExecutor.java b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..0f6f04d02604a1779821fd1c6fd74f79d8be8504 --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/java/io/datavines/connector/plugin/MariadbExecutor.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.connector.plugin; + +import io.datavines.common.datasource.jdbc.BaseJdbcDataSourceInfo; +import io.datavines.common.datasource.jdbc.JdbcConnectionInfo; +import io.datavines.connector.api.DataSourceClient; + +public class MariadbExecutor extends BaseJdbcExecutor { + + public MariadbExecutor(DataSourceClient dataSourceClient) { + super(dataSourceClient); + } + + @Override + public BaseJdbcDataSourceInfo getDatasourceInfo(JdbcConnectionInfo jdbcConnectionInfo) { + return new MariadbDataSourceInfo(jdbcConnectionInfo); + } +} diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/resources/META-INF/plugins/io.datavines.connector.api.ConnectorFactory b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/resources/META-INF/plugins/io.datavines.connector.api.ConnectorFactory new file mode 100644 index 0000000000000000000000000000000000000000..f8a7dd6df819c5c702411d3de8d096d94aab6fbc --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-mariadb/src/main/resources/META-INF/plugins/io.datavines.connector.api.ConnectorFactory @@ -0,0 +1 @@ +mariadb=io.datavines.connector.plugin.MariadbConnectorFactory \ No newline at end of file diff --git a/datavines-connector/datavines-connector-plugins/pom.xml b/datavines-connector/datavines-connector-plugins/pom.xml index 2b2ec91f9614eaeffa8c94c4c110c5f0501abc9e..0c4cbb4cfdd839caec2c55a580a49074f1af9047 100644 --- a/datavines-connector/datavines-connector-plugins/pom.xml +++ b/datavines-connector/datavines-connector-plugins/pom.xml @@ -33,6 +33,7 @@ datavines-connector-jdbc datavines-connector-mysql + datavines-connector-mariadb datavines-connector-hive datavines-connector-impala datavines-connector-clickhouse diff --git a/pom.xml b/pom.xml index 973de1d701d0e589ba84f13d3c4256e71fbace38..4929867f1be539df8fc71945495da831339ad608 100644 --- a/pom.xml +++ b/pom.xml @@ -100,6 +100,7 @@ 1.3.0 1.8 2.1.0 + 3.1.4 6.1.0.jre8 8.1.2.141 4.0.3 @@ -571,6 +572,13 @@ mssql-jdbc ${sqlserver.version} + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.version} + + com.dameng DmJdbcDriver18