@@ -85,6 +85,8 @@ public final class PostgresqlConnectionConfiguration {
85
85
86
86
private final int port ;
87
87
88
+ private final int preparedStatementCacheQueries ;
89
+
88
90
private final String socket ;
89
91
90
92
private final String username ;
@@ -95,15 +97,13 @@ public final class PostgresqlConnectionConfiguration {
95
97
96
98
private final boolean tcpNoDelay ;
97
99
98
- private final int preparedStatementCacheQueries ;
99
-
100
100
private PostgresqlConnectionConfiguration (String applicationName , boolean autodetectExtensions , @ Nullable Duration connectTimeout , @ Nullable String database , LogLevel errorResponseLogLevel ,
101
101
List <Extension > extensions ,
102
102
ToIntFunction <String > fetchSize , boolean forceBinary ,
103
103
LogLevel noticeLogLevel , @ Nullable String host ,
104
- @ Nullable Map <String , String > options , @ Nullable CharSequence password , int port , @ Nullable String schema ,
105
- @ Nullable String socket , boolean tcpKeepAlive , boolean tcpNoDelay , String username , SSLConfig sslConfig ,
106
- int preparedStatementCacheQueries ) {
104
+ @ Nullable Map <String , String > options , @ Nullable CharSequence password , int port , int preparedStatementCacheQueries , @ Nullable String schema ,
105
+ @ Nullable String socket , boolean tcpKeepAlive , boolean tcpNoDelay ,
106
+ String username , SSLConfig sslConfig ) {
107
107
this .applicationName = Assert .requireNonNull (applicationName , "applicationName must not be null" );
108
108
this .autodetectExtensions = autodetectExtensions ;
109
109
this .connectTimeout = connectTimeout ;
@@ -122,12 +122,12 @@ private PostgresqlConnectionConfiguration(String applicationName, boolean autode
122
122
123
123
this .password = password ;
124
124
this .port = port ;
125
+ this .preparedStatementCacheQueries = preparedStatementCacheQueries ;
125
126
this .socket = socket ;
126
127
this .username = Assert .requireNonNull (username , "username must not be null" );
127
128
this .sslConfig = sslConfig ;
128
129
this .tcpKeepAlive = tcpKeepAlive ;
129
130
this .tcpNoDelay = tcpNoDelay ;
130
- this .preparedStatementCacheQueries = preparedStatementCacheQueries ;
131
131
}
132
132
133
133
/**
@@ -216,6 +216,10 @@ int getPort() {
216
216
return this .port ;
217
217
}
218
218
219
+ int getPreparedStatementCacheQueries () {
220
+ return this .preparedStatementCacheQueries ;
221
+ }
222
+
219
223
@ Nullable
220
224
String getSocket () {
221
225
return this .socket ;
@@ -255,7 +259,6 @@ boolean isTcpNoDelay() {
255
259
boolean isUseSocket () {
256
260
return getSocket () != null ;
257
261
}
258
-
259
262
SSLConfig getSslConfig () {
260
263
return this .sslConfig ;
261
264
}
@@ -271,10 +274,6 @@ ConnectionSettings getConnectionSettings() {
271
274
.build ();
272
275
}
273
276
274
- int getPreparedStatementCacheQueries () {
275
- return this .preparedStatementCacheQueries ;
276
- }
277
-
278
277
private static String obfuscate (int length ) {
279
278
280
279
StringBuilder builder = new StringBuilder ();
@@ -323,6 +322,8 @@ public static final class Builder {
323
322
324
323
private int port = DEFAULT_PORT ;
325
324
325
+ private int preparedStatementCacheQueries = -1 ;
326
+
326
327
@ Nullable
327
328
private String schema ;
328
329
@@ -354,8 +355,6 @@ public static final class Builder {
354
355
@ Nullable
355
356
private String username ;
356
357
357
- private int preparedStatementCacheQueries = -1 ;
358
-
359
358
private Builder () {
360
359
}
361
360
@@ -402,9 +401,10 @@ public PostgresqlConnectionConfiguration build() {
402
401
}
403
402
404
403
return new PostgresqlConnectionConfiguration (this .applicationName , this .autodetectExtensions , this .connectTimeout , this .database , this .errorResponseLogLevel , this .extensions ,
405
- this .fetchSize , this .forceBinary , this .noticeLogLevel , this .host , this .options , this .password , this .port , this .schema , this .socket , this .tcpKeepAlive , this .tcpNoDelay , this .username
406
- , this .createSslConfig (),
407
- this .preparedStatementCacheQueries );
404
+ this .fetchSize , this .forceBinary , this .noticeLogLevel , this .host , this .options , this .password , this .port , this .preparedStatementCacheQueries , this .schema , this .socket , this .tcpKeepAlive , this .tcpNoDelay , this .username
405
+ ,
406
+ this .createSslConfig ()
407
+ );
408
408
}
409
409
410
410
/**
@@ -580,6 +580,19 @@ public Builder port(int port) {
580
580
return this ;
581
581
}
582
582
583
+ /**
584
+ * Configure the preparedStatementCacheQueries. The default is {@code -1}, meaning there's no limit. The value of {@code 0} disables the cache. Any other value specifies the cache size.
585
+ *
586
+ * @param preparedStatementCacheQueries the preparedStatementCacheQueries
587
+ * @return this {@link Builder}
588
+ * @throws IllegalArgumentException if {@code username} is {@code null}
589
+ * @since 0.8.1
590
+ */
591
+ public Builder preparedStatementCacheQueries (int preparedStatementCacheQueries ) {
592
+ this .preparedStatementCacheQueries = preparedStatementCacheQueries ;
593
+ return this ;
594
+ }
595
+
583
596
/**
584
597
* Configure the schema.
585
598
*
@@ -722,19 +735,6 @@ public Builder username(String username) {
722
735
return this ;
723
736
}
724
737
725
- /**
726
- * Configure the preparedStatementCacheQueries. The default is {@code -1}, meaning there's no limit. The value of {@code 0} disables the cache. Any other value specifies the cache size.
727
- *
728
- * @param preparedStatementCacheQueries the preparedStatementCacheQueries
729
- * @return this {@link Builder}
730
- * @throws IllegalArgumentException if {@code username} is {@code null}
731
- * @since 0.8.1
732
- */
733
- public Builder preparedStatementCacheQueries (int preparedStatementCacheQueries ) {
734
- this .preparedStatementCacheQueries = preparedStatementCacheQueries ;
735
- return this ;
736
- }
737
-
738
738
@ Override
739
739
public String toString () {
740
740
return "Builder{" +
@@ -751,8 +751,8 @@ public String toString() {
751
751
", parameters='" + this .options + '\'' +
752
752
", password='" + obfuscate (this .password != null ? this .password .length () : 0 ) + '\'' +
753
753
", port=" + this .port +
754
+ ", preparedStatementCacheQueries='" + this .preparedStatementCacheQueries + '\'' +
754
755
", schema='" + this .schema + '\'' +
755
- ", username='" + this .username + '\'' +
756
756
", socket='" + this .socket + '\'' +
757
757
", sslContextBuilderCustomizer='" + this .sslContextBuilderCustomizer + '\'' +
758
758
", sslMode='" + this .sslMode + '\'' +
@@ -762,7 +762,7 @@ public String toString() {
762
762
", sslHostnameVerifier='" + this .sslHostnameVerifier + '\'' +
763
763
", tcpKeepAlive='" + this .tcpKeepAlive + '\'' +
764
764
", tcpNoDelay='" + this .tcpNoDelay + '\'' +
765
- ", preparedStatementCacheQueries ='" + this .preparedStatementCacheQueries + '\'' +
765
+ ", username ='" + this .username + '\'' +
766
766
'}' ;
767
767
}
768
768
0 commit comments