diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 940404707d6b4..091e36830b4e5 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -55,6 +55,7 @@
1. Agent: Simplify the use of Agent's Docker Image - [#33356](https://github.com/apache/shardingsphere/pull/33356)
1. Mode: Support modifying Hikari-CP configurations via props in standalone mode [#34185](https://github.com/apache/shardingsphere/pull/34185)
1. Encrypt: Support insert statement rewrite use quote [#34259](https://github.com/apache/shardingsphere/pull/34259)
+1. Infra: Support connecting to Firebird via jdbcUrl containing the absolute path to fdb - [#34335](https://github.com/apache/shardingsphere/pull/34335)
### Bug Fixes
diff --git a/infra/database/type/firebird/pom.xml b/infra/database/type/firebird/pom.xml
index 95ef8db8741b5..c32065c71186a 100644
--- a/infra/database/type/firebird/pom.xml
+++ b/infra/database/type/firebird/pom.xml
@@ -33,6 +33,13 @@
${project.version}
+
+ org.firebirdsql.jdbc
+ jaybird
+ provided
+ true
+
+
org.apache.shardingsphere
shardingsphere-test-util
diff --git a/infra/database/type/firebird/src/main/java/org/apache/shardingsphere/infra/database/firebird/connector/FirebirdConnectionPropertiesParser.java b/infra/database/type/firebird/src/main/java/org/apache/shardingsphere/infra/database/firebird/connector/FirebirdConnectionPropertiesParser.java
index 0f803ebd0e64c..7d7392c8ef805 100644
--- a/infra/database/type/firebird/src/main/java/org/apache/shardingsphere/infra/database/firebird/connector/FirebirdConnectionPropertiesParser.java
+++ b/infra/database/type/firebird/src/main/java/org/apache/shardingsphere/infra/database/firebird/connector/FirebirdConnectionPropertiesParser.java
@@ -17,11 +17,14 @@
package org.apache.shardingsphere.infra.database.firebird.connector;
+import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.database.core.connector.ConnectionProperties;
import org.apache.shardingsphere.infra.database.core.connector.ConnectionPropertiesParser;
import org.apache.shardingsphere.infra.database.core.connector.StandardConnectionProperties;
-import org.apache.shardingsphere.infra.database.core.connector.url.JdbcUrl;
-import org.apache.shardingsphere.infra.database.core.connector.url.StandardJdbcUrlParser;
+import org.firebirdsql.gds.impl.DbAttachInfo;
+import org.firebirdsql.gds.impl.GDSFactory;
+import org.firebirdsql.gds.impl.GDSType;
+import org.firebirdsql.jdbc.FBDriver;
import java.util.Properties;
@@ -30,12 +33,18 @@
*/
public final class FirebirdConnectionPropertiesParser implements ConnectionPropertiesParser {
- private static final int DEFAULT_PORT = 3050;
-
+ @SneakyThrows(Exception.class)
@Override
public ConnectionProperties parse(final String url, final String username, final String catalog) {
- JdbcUrl jdbcUrl = new StandardJdbcUrlParser().parse(url);
- return new StandardConnectionProperties(jdbcUrl.getHostname(), jdbcUrl.getPort(DEFAULT_PORT), jdbcUrl.getDatabase(), null, jdbcUrl.getQueryProperties(), new Properties());
+ GDSType type = GDSFactory.getTypeForProtocol(url);
+ String databaseURL = GDSFactory.getDatabasePath(type, url);
+ DbAttachInfo dbAttachInfo = DbAttachInfo.parseConnectString(databaseURL);
+ String attachObjectName = dbAttachInfo.getAttachObjectName();
+ String databaseName = attachObjectName.contains("?") ? attachObjectName.split("\\?")[0] : attachObjectName;
+ Properties queryProperties = new Properties();
+ queryProperties.putAll(FBDriver.normalizeProperties(url, new Properties()));
+ return new StandardConnectionProperties(dbAttachInfo.getServerName(), dbAttachInfo.getPortNumber(),
+ databaseName, null, queryProperties, new Properties());
}
@Override
diff --git a/infra/database/type/firebird/src/test/java/org/apache/shardingsphere/infra/database/firebird/connector/FirebirdConnectionPropertiesParserTest.java b/infra/database/type/firebird/src/test/java/org/apache/shardingsphere/infra/database/firebird/connector/FirebirdConnectionPropertiesParserTest.java
index a980af1367ca9..604f617f8aa32 100644
--- a/infra/database/type/firebird/src/test/java/org/apache/shardingsphere/infra/database/firebird/connector/FirebirdConnectionPropertiesParserTest.java
+++ b/infra/database/type/firebird/src/test/java/org/apache/shardingsphere/infra/database/firebird/connector/FirebirdConnectionPropertiesParserTest.java
@@ -19,10 +19,10 @@
import org.apache.shardingsphere.infra.database.core.connector.ConnectionProperties;
import org.apache.shardingsphere.infra.database.core.connector.ConnectionPropertiesParser;
-import org.apache.shardingsphere.infra.database.core.exception.UnrecognizedDatabaseURLException;
import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.ParameterizedTest;
@@ -30,11 +30,13 @@
import org.junit.jupiter.params.provider.ArgumentsProvider;
import org.junit.jupiter.params.provider.ArgumentsSource;
+import java.sql.SQLNonTransientConnectionException;
import java.util.Properties;
import java.util.stream.Stream;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
class FirebirdConnectionPropertiesParserTest {
@@ -54,14 +56,29 @@ void assertNewConstructor(final String name, final String url, final String host
@Test
void assertNewConstructorFailure() {
- assertThrows(UnrecognizedDatabaseURLException.class, () -> parser.parse("jdbc:firebirdsql:xxxxxxxx", null, null));
+ assertDoesNotThrow(() -> parser.parse("jdbc:firebirdsql:xxxxxxxx", null, null));
+ assertThrows(SQLNonTransientConnectionException.class, () -> parser.parse("jdbc:firebirdsql://localhost:c:/data/db/test.fdb", null, null));
}
private static class NewConstructorTestCaseArgumentsProvider implements ArgumentsProvider {
@Override
public Stream extends Arguments> provideArguments(final ExtensionContext extensionContext) {
- return Stream.of(Arguments.of("simple", "jdbc:firebirdsql://127.0.0.1/foo_ds", "127.0.0.1", 3050, "foo_ds", null, new Properties()));
+ return Stream.of(
+ Arguments.of("simple_first", "jdbc:firebirdsql://127.0.0.1/foo_ds", "127.0.0.1", 3050, "foo_ds", null, new Properties()),
+ Arguments.of("simple_second", "jdbc:firebird://localhost:32783//var/lib/firebird/data/demo_ds_2.fdb",
+ "localhost", 32783, "/var/lib/firebird/data/demo_ds_2.fdb", null, new Properties()),
+ Arguments.of("simple_third", "jdbc:firebirdsql://localhost/database?socket_buffer_size=32767", "localhost", 3050, "database", null, PropertiesBuilder.build(
+ new PropertiesBuilder.Property("socketBufferSize", "32767"))),
+ Arguments.of("complex",
+ "jdbc:firebirdsql://localhost/database?socket_buffer_size=32767"
+ + "&TRANSACTION_REPEATABLE_READ=concurrency,write,no_wait&columnLabelForName&soTimeout=1000&nonStandard2=value2",
+ "localhost", 3050, "database", null, PropertiesBuilder.build(
+ new PropertiesBuilder.Property("socketBufferSize", "32767"),
+ new PropertiesBuilder.Property("TRANSACTION_REPEATABLE_READ", "concurrency,write,no_wait"),
+ new PropertiesBuilder.Property("columnLabelForName", ""),
+ new PropertiesBuilder.Property("soTimeout", "1000"),
+ new PropertiesBuilder.Property("nonStandard2", "value2"))));
}
}
}
diff --git a/pom.xml b/pom.xml
index 8851b93a3b2be..47dfbde8720d5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -132,6 +132,7 @@
1.6.0
3.3.6
0.288.1
+ 5.0.6.java8
4.0.3
@@ -489,6 +490,12 @@
${presto.version}
test
+
+ org.firebirdsql.jdbc
+ jaybird
+ ${jaybird.version}
+ test
+
com.zaxxer