@@ -16,7 +16,6 @@ public class DuckDBDriver implements java.sql.Driver {
1616 public static final String JDBC_STREAM_RESULTS = "jdbc_stream_results" ;
1717 public static final String JDBC_AUTO_COMMIT = "jdbc_auto_commit" ;
1818 public static final String JDBC_PIN_DB = "jdbc_pin_db" ;
19- public static final String JDBC_IGNORE_UNSUPPORTED_OPTIONS = "jdbc_ignore_unsupported_options" ;
2019
2120 static final String DUCKDB_URL_PREFIX = "jdbc:duckdb:" ;
2221 static final String MEMORY_DB = ":memory:" ;
@@ -34,9 +33,6 @@ public class DuckDBDriver implements java.sql.Driver {
3433 private static boolean pinnedDbRefsShutdownHookRegistered = false ;
3534 private static boolean pinnedDbRefsShutdownHookRun = false ;
3635
37- private static final Set <String > supportedOptions = new LinkedHashSet <>();
38- private static final ReentrantLock supportedOptionsLock = new ReentrantLock ();
39-
4036 static {
4137 try {
4238 DriverManager .registerDriver (new DuckDBDriver ());
@@ -56,20 +52,13 @@ public Connection connect(String url, Properties info) throws SQLException {
5652 props = (Properties ) info .clone ();
5753 }
5854
59- // URL options
6055 ParsedProps pp = parsePropsFromUrl (url );
6156 for (Map .Entry <String , String > en : pp .props .entrySet ()) {
6257 props .put (en .getKey (), en .getValue ());
6358 }
6459
65- // Ignore unsupported
66- removeUnsupportedOptions (props );
67-
68- // Read-only option
6960 String readOnlyStr = removeOption (props , DUCKDB_READONLY_PROPERTY );
7061 boolean readOnly = isStringTruish (readOnlyStr , false );
71-
72- // Client name option
7362 props .put ("duckdb_api" , "jdbc" );
7463
7564 // Apache Spark passes this option when SELECT on a JDBC DataSource
@@ -78,7 +67,6 @@ public Connection connect(String url, Properties info) throws SQLException {
7867 // to be established.
7968 props .remove ("path" );
8069
81- // DuckLake options
8270 String ducklake = removeOption (props , DUCKLAKE_OPTION );
8371 String ducklakeAlias = removeOption (props , DUCKLAKE_ALIAS_OPTION , DUCKLAKE_OPTION );
8472 final String shortUrl ;
@@ -95,13 +83,13 @@ public Connection connect(String url, Properties info) throws SQLException {
9583 shortUrl = pp .shortUrl ;
9684 }
9785
98- // Pin DB option
9986 String pinDbOptStr = removeOption (props , JDBC_PIN_DB );
10087 boolean pinDBOpt = isStringTruish (pinDbOptStr , false );
10188
102- // Create connection
10389 DuckDBConnection conn = DuckDBConnection .newConnection (shortUrl , readOnly , props );
90+
10491 pinDB (pinDBOpt , shortUrl , conn );
92+
10593 initDucklake (conn , shortUrl , ducklake , ducklakeAlias );
10694
10795 return conn ;
@@ -128,8 +116,6 @@ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws
128116 list .add (createDriverPropInfo (JDBC_AUTO_COMMIT , "" , "Set default auto-commit mode" ));
129117 list .add (createDriverPropInfo (JDBC_PIN_DB , "" ,
130118 "Do not close the DB instance after all connections to it are closed" ));
131- list .add (createDriverPropInfo (JDBC_IGNORE_UNSUPPORTED_OPTIONS , "" ,
132- "Silently discard unsupported connection options" ));
133119 list .sort ((o1 , o2 ) -> o1 .name .compareToIgnoreCase (o2 .name ));
134120 return list .toArray (new DriverPropertyInfo [0 ]);
135121 }
@@ -265,38 +251,6 @@ private static DriverPropertyInfo createDriverPropInfo(String name, String value
265251 return dpi ;
266252 }
267253
268- private static void removeUnsupportedOptions (Properties props ) throws SQLException {
269- String ignoreStr = removeOption (props , JDBC_IGNORE_UNSUPPORTED_OPTIONS );
270- boolean ignore = isStringTruish (ignoreStr , false );
271- if (!ignore ) {
272- return ;
273- }
274- supportedOptionsLock .lock ();
275- try {
276- if (supportedOptions .isEmpty ()) {
277- Driver driver = DriverManager .getDriver (DUCKDB_URL_PREFIX );
278- Properties dpiProps = new Properties ();
279- dpiProps .put ("threads" , 1 );
280- DriverPropertyInfo [] dpis = driver .getPropertyInfo (DUCKDB_URL_PREFIX , dpiProps );
281- for (DriverPropertyInfo dpi : dpis ) {
282- supportedOptions .add (dpi .name );
283- }
284- }
285- List <String > unsupportedNames = new ArrayList <>();
286- for (Object nameObj : props .keySet ()) {
287- String name = String .valueOf (nameObj );
288- if (!supportedOptions .contains (name )) {
289- unsupportedNames .add (name );
290- }
291- }
292- for (String name : unsupportedNames ) {
293- props .remove (name );
294- }
295- } finally {
296- supportedOptionsLock .unlock ();
297- }
298- }
299-
300254 private static class ParsedProps {
301255 final String shortUrl ;
302256 final LinkedHashMap <String , String > props ;
0 commit comments