Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MariaDB Connector/J JDBC driver #2391

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ jobs:
uses: gradle/actions/setup-gradle@v4

- name: Execute Gradle 'integrationTestJdbc' task
run: ./gradlew integrationTestJdbc ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }}
run: ./gradlew integrationTestJdbc -Dscalardb.jdbc.url=jdbc:mariadb://localhost:3306 ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }}

- name: Upload Gradle test reports
if: always()
Expand Down Expand Up @@ -1496,7 +1496,7 @@ jobs:
uses: gradle/actions/setup-gradle@v4

- name: Execute Gradle 'integrationTestJdbc' task
run: ./gradlew integrationTestJdbc ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }}
run: ./gradlew integrationTestJdbc -Dscalardb.jdbc.url=jdbc:mariadb://localhost:3306 ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }}

- name: Upload Gradle test reports
if: always()
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ subprojects {
sqlserverDriverVersion = '11.2.3.jre8'
sqliteDriverVersion = '3.47.1.0'
yugabyteDriverVersion = '42.7.3-yb-2'
mariadDbDriverVersion = '3.5.1'
picocliVersion = '4.7.6'
commonsTextVersion = '1.13.0'
junitVersion = '5.11.4'
Expand Down
1 change: 1 addition & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ dependencies {
implementation "com.microsoft.sqlserver:mssql-jdbc:${sqlserverDriverVersion}"
implementation "org.xerial:sqlite-jdbc:${sqliteDriverVersion}"
implementation "com.yugabyte:jdbc-yugabytedb:${yugabyteDriverVersion}"
implementation "org.mariadb.jdbc:mariadb-java-client:${mariadDbDriverVersion}"
implementation "org.apache.commons:commons-text:${commonsTextVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public static RdbEngineStrategy create(JdbcConfig config) {
return new RdbEngineSqlite();
} else if (jdbcUrl.startsWith("jdbc:yugabytedb:")) {
return new RdbEngineYugabyte();
} else if (jdbcUrl.startsWith("jdbc:mariadb:")) {
return new RdbEngineMariaDB();
} else {
throw new IllegalArgumentException(
CoreError.JDBC_RDB_ENGINE_NOT_SUPPORTED.buildMessage(jdbcUrl));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.scalar.db.storage.jdbc;

import com.scalar.db.io.DataType;
import java.sql.Driver;
import java.sql.JDBCType;

class RdbEngineMariaDB extends RdbEngineMysql {
@Override
public Driver getDriver() {
return new org.mariadb.jdbc.Driver();
}

@Override
public DataType getDataTypeForScalarDb(
JDBCType type, String typeName, int columnSize, int digits, String columnDescription) {
if (type == JDBCType.BOOLEAN) {
// MariaDB JDBC driver maps TINYINT(1) type as a BOOLEAN JDBC type which differs from the
// MySQL driver which maps it to a BIT type.
return DataType.BOOLEAN;
} else {
return super.getDataTypeForScalarDb(type, typeName, columnSize, digits, columnDescription);
}
}
}
Loading