Skip to content

Commit

Permalink
Added client application connection attributes
Browse files Browse the repository at this point in the history
Changed program name
  • Loading branch information
AdalbertMemSQL committed Nov 13, 2023
1 parent a7ce51e commit 93924dd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (C) Red Gate Software Ltd 2010-2023
*
* Licensed 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 org.flywaydb.database;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import org.flywaydb.core.api.FlywayException;
import org.flywaydb.core.extensibility.PluginMetadata;
import org.flywaydb.core.internal.util.FileUtils;

public class SingleStoreDatabaseExtension implements PluginMetadata {
public String getDescription() {
return "SingleStoreDB database support " + readVersion() + " by Redgate";
}

public static String readVersion() {
try {
return FileUtils.copyToString(
SingleStoreDatabaseExtension.class.getClassLoader().getResourceAsStream("org/flywaydb/database/version.txt"),
StandardCharsets.UTF_8);
} catch (IOException e) {
throw new FlywayException("Unable to read extension version: " + e.getMessage(), e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import org.flywaydb.core.internal.jdbc.StatementInterceptor;
import org.flywaydb.core.internal.parser.Parser;
import org.flywaydb.core.internal.parser.ParsingContext;
import org.flywaydb.database.SingleStoreDatabaseExtension;

import java.sql.Connection;
import java.sql.Types;
import java.util.Arrays;
import java.util.Properties;

public class SingleStoreDatabaseType extends BaseDatabaseType {
@Override
Expand Down Expand Up @@ -56,6 +59,19 @@ public boolean handlesDatabaseProductNameAndVersion(String databaseProductName,
return databaseProductName.contains("SingleStore");
}

@Override
public void setDefaultConnectionProps(String url, Properties props, ClassLoader classLoader) {
props.put("connectionAttributes",
String.format("_connector_name:%s,_connector_version:%s,_product_version:%s,program_name:%s,program_version:%s,program_vendor:%s",
"SingleStoreDB Flyway connector",
SingleStoreDatabaseExtension.readVersion(),
SingleStoreDatabaseExtension.readVersion(),
"Redgate_Flyway",
SingleStoreDatabaseExtension.readVersion(),
"Redgate"
));
}

@Override
public Database createDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor) {
return new SingleStoreDatabase(configuration, jdbcConnectionFactory, statementInterceptor);
Expand Down

0 comments on commit 93924dd

Please sign in to comment.