Skip to content

Commit 722ca35

Browse files
committed
When schema specified, change to use connection.setSchema() rather than connection Properties
Using Properties with a properties.setProperty("schema", ..) is not supported by Postgres. Changing to use connection.setSchema() looks like a more robust approach.
1 parent b10985e commit 722ca35

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

ebean-datasource/src/main/java/io/ebean/datasource/pool/ConnectionPool.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ final class ConnectionPool implements DataSourcePool {
4141
private final String driver;
4242
private final String url;
4343
private final String user;
44+
private final String schema;
4445
private final String heartbeatsql;
4546
private final int heartbeatFreqSecs;
4647
private final int heartbeatTimeoutSeconds;
@@ -112,6 +113,7 @@ final class ConnectionPool implements DataSourcePool {
112113
this.applicationName = params.getApplicationName();
113114
this.clientInfo = params.getClientInfo();
114115
this.queue = new PooledConnectionQueue(this);
116+
this.schema = params.getSchema();
115117
this.user = params.getUsername();
116118
if (user == null) {
117119
throw new DataSourceConfigurationException("DataSource user is not set? url is [" + url + "]");
@@ -123,10 +125,6 @@ final class ConnectionPool implements DataSourcePool {
123125
this.connectionProps = new Properties();
124126
this.connectionProps.setProperty("user", user);
125127
this.connectionProps.setProperty("password", pw);
126-
final String schema = params.getSchema();
127-
if (schema != null) {
128-
this.connectionProps.setProperty("schema", schema);
129-
}
130128

131129
Map<String, String> customProperties = params.getCustomProperties();
132130
if (customProperties != null) {
@@ -430,6 +428,9 @@ private void initConnection(Connection conn) throws SQLException {
430428
if (readOnly) {
431429
conn.setReadOnly(true);
432430
}
431+
if (schema != null) {
432+
conn.setSchema(schema);
433+
}
433434
if (applicationName != null) {
434435
try {
435436
conn.setClientInfo("ApplicationName", applicationName);

0 commit comments

Comments
 (0)