@@ -101,6 +101,12 @@ public final class MySqlConnectionConfiguration {
101101
102102 private final List <String > sessionVariables ;
103103
104+ @ Nullable
105+ private final Duration lockWaitTimeout ;
106+
107+ @ Nullable
108+ private final Duration statementTimeout ;
109+
104110 @ Nullable
105111 private final Path loadLocalInfilePath ;
106112
@@ -130,7 +136,7 @@ private MySqlConnectionConfiguration(
130136 boolean forceConnectionTimeZoneToSession ,
131137 String user , @ Nullable CharSequence password , @ Nullable String database ,
132138 boolean createDatabaseIfNotExist , @ Nullable Predicate <String > preferPrepareStatement ,
133- List <String > sessionVariables ,
139+ List <String > sessionVariables , @ Nullable Duration lockWaitTimeout , @ Nullable Duration statementTimeout ,
134140 @ Nullable Path loadLocalInfilePath , int localInfileBufferSize ,
135141 int queryCacheSize , int prepareCacheSize ,
136142 Set <CompressionAlgorithm > compressionAlgorithms , int zstdCompressionLevel ,
@@ -154,6 +160,8 @@ private MySqlConnectionConfiguration(
154160 this .createDatabaseIfNotExist = createDatabaseIfNotExist ;
155161 this .preferPrepareStatement = preferPrepareStatement ;
156162 this .sessionVariables = sessionVariables ;
163+ this .lockWaitTimeout = lockWaitTimeout ;
164+ this .statementTimeout = statementTimeout ;
157165 this .loadLocalInfilePath = loadLocalInfilePath ;
158166 this .localInfileBufferSize = localInfileBufferSize ;
159167 this .queryCacheSize = queryCacheSize ;
@@ -245,6 +253,16 @@ List<String> getSessionVariables() {
245253 return sessionVariables ;
246254 }
247255
256+ @ Nullable
257+ Duration getLockWaitTimeout () {
258+ return lockWaitTimeout ;
259+ }
260+
261+ @ Nullable
262+ Duration getStatementTimeout () {
263+ return statementTimeout ;
264+ }
265+
248266 @ Nullable
249267 Path getLoadLocalInfilePath () {
250268 return loadLocalInfilePath ;
@@ -309,6 +327,8 @@ public boolean equals(Object o) {
309327 createDatabaseIfNotExist == that .createDatabaseIfNotExist &&
310328 Objects .equals (preferPrepareStatement , that .preferPrepareStatement ) &&
311329 sessionVariables .equals (that .sessionVariables ) &&
330+ Objects .equals (lockWaitTimeout , that .lockWaitTimeout ) &&
331+ Objects .equals (statementTimeout , that .statementTimeout ) &&
312332 Objects .equals (loadLocalInfilePath , that .loadLocalInfilePath ) &&
313333 localInfileBufferSize == that .localInfileBufferSize &&
314334 queryCacheSize == that .queryCacheSize &&
@@ -325,9 +345,14 @@ public int hashCode() {
325345 return Objects .hash (isHost , domain , port , ssl , tcpKeepAlive , tcpNoDelay , connectTimeout ,
326346 preserveInstants , connectionTimeZone , forceConnectionTimeZoneToSession ,
327347 zeroDateOption , user , password , database , createDatabaseIfNotExist ,
328- preferPrepareStatement , sessionVariables , loadLocalInfilePath ,
329- localInfileBufferSize , queryCacheSize , prepareCacheSize , compressionAlgorithms ,
330- zstdCompressionLevel , loopResources , extensions , passwordPublisher );
348+ preferPrepareStatement ,
349+ sessionVariables ,
350+ lockWaitTimeout ,
351+ statementTimeout ,
352+ loadLocalInfilePath , localInfileBufferSize ,
353+ queryCacheSize , prepareCacheSize ,
354+ compressionAlgorithms , zstdCompressionLevel ,
355+ loopResources , extensions , passwordPublisher );
331356 }
332357
333358 @ Override
@@ -343,6 +368,8 @@ public String toString() {
343368 ", database='" + database + "', createDatabaseIfNotExist=" + createDatabaseIfNotExist +
344369 ", preferPrepareStatement=" + preferPrepareStatement +
345370 ", sessionVariables=" + sessionVariables +
371+ ", lockWaitTimeout=" + lockWaitTimeout +
372+ ", statementTimeout=" + statementTimeout +
346373 ", loadLocalInfilePath=" + loadLocalInfilePath +
347374 ", localInfileBufferSize=" + localInfileBufferSize +
348375 ", queryCacheSize=" + queryCacheSize + ", prepareCacheSize=" + prepareCacheSize +
@@ -361,6 +388,8 @@ public String toString() {
361388 ", database='" + database + "', createDatabaseIfNotExist=" + createDatabaseIfNotExist +
362389 ", preferPrepareStatement=" + preferPrepareStatement +
363390 ", sessionVariables=" + sessionVariables +
391+ ", lockWaitTimeout=" + lockWaitTimeout +
392+ ", statementTimeout=" + statementTimeout +
364393 ", loadLocalInfilePath=" + loadLocalInfilePath +
365394 ", localInfileBufferSize=" + localInfileBufferSize +
366395 ", queryCacheSize=" + queryCacheSize +
@@ -433,6 +462,12 @@ public static final class Builder {
433462 @ Nullable
434463 private Predicate <String > preferPrepareStatement ;
435464
465+ @ Nullable
466+ private Duration lockWaitTimeout ;
467+
468+ @ Nullable
469+ private Duration statementTimeout ;
470+
436471 private List <String > sessionVariables = Collections .emptyList ();
437472
438473 @ Nullable
@@ -486,7 +521,11 @@ public MySqlConnectionConfiguration build() {
486521 connectionTimeZone ,
487522 forceConnectionTimeZoneToSession ,
488523 user , password , database ,
489- createDatabaseIfNotExist , preferPrepareStatement , sessionVariables , loadLocalInfilePath ,
524+ createDatabaseIfNotExist , preferPrepareStatement ,
525+ sessionVariables ,
526+ lockWaitTimeout ,
527+ statementTimeout ,
528+ loadLocalInfilePath ,
490529 localInfileBufferSize , queryCacheSize , prepareCacheSize ,
491530 compressionAlgorithms , zstdCompressionLevel , loopResources ,
492531 Extensions .from (extensions , autodetectExtensions ), passwordPublisher );
@@ -911,6 +950,30 @@ public Builder sessionVariables(String... sessionVariables) {
911950 return this ;
912951 }
913952
953+ /**
954+ * Configures the lock wait timeout. Default to use the server-side default value.
955+ *
956+ * @param lockWaitTimeout the lock wait timeout, or {@code null} to use the server-side default value.
957+ * @return {@link Builder this}
958+ * @since 1.1.3
959+ */
960+ public Builder lockWaitTimeout (@ Nullable Duration lockWaitTimeout ) {
961+ this .lockWaitTimeout = lockWaitTimeout ;
962+ return this ;
963+ }
964+
965+ /**
966+ * Configures the statement timeout. Default to use the server-side default value.
967+ *
968+ * @param statementTimeout the statement timeout, or {@code null} to use the server-side default value.
969+ * @return {@link Builder this}
970+ * @since 1.1.3
971+ */
972+ public Builder statementTimeout (@ Nullable Duration statementTimeout ) {
973+ this .statementTimeout = statementTimeout ;
974+ return this ;
975+ }
976+
914977 /**
915978 * Configures to allow the {@code LOAD DATA LOCAL INFILE} statement in the given {@code path} or
916979 * disallow the statement. Default to {@code null} which means not allow the statement.
0 commit comments