@@ -34,6 +34,16 @@ public static OracleConnectOptions wrap(SqlConnectOptions options) {
3434 }
3535 }
3636
37+ public static final String DEFAULT_HOST = "localhost" ;
38+ public static final int DEFAULT_PORT = 1521 ;
39+ public static final String DEFAULT_USER = "" ;
40+ public static final String DEFAULT_PASSWORD = "" ;
41+ public static final String DEFAULT_DATABASE = "" ;
42+
43+ private String serviceId ;
44+ private String serviceName ;
45+ private ServerMode serverMode ;
46+ private String instanceName ;
3747 // Support TNS_ADMIN (tnsnames.ora, ojdbc.properties).
3848 private String tnsAdmin ;
3949
@@ -42,6 +52,10 @@ public OracleConnectOptions() {
4252
4353 public OracleConnectOptions (OracleConnectOptions other ) {
4454 super (other );
55+ this .serviceId = other .serviceId ;
56+ this .serviceName = other .serviceName ;
57+ this .serverMode = other .serverMode ;
58+ this .instanceName = other .instanceName ;
4559 this .tnsAdmin = other .tnsAdmin ;
4660 }
4761
@@ -68,6 +82,80 @@ public static OracleConnectOptions fromUri(String connectionUri) throws IllegalA
6882
6983 // Oracle-specific options
7084
85+ /**
86+ * @return the Oracle service identifier (SID)
87+ */
88+ public String getServiceId () {
89+ return serviceId ;
90+ }
91+
92+ /**
93+ * Set the Oracle service identifier (SID).
94+ * If set, the client will build an Oracle connection URL using SID instead of the EZConnect format.
95+ *
96+ * @param serviceId the service identifier
97+ * @return a reference to this, so the API can be used fluently
98+ */
99+ public OracleConnectOptions setServiceId (String serviceId ) {
100+ this .serviceId = serviceId ;
101+ return this ;
102+ }
103+
104+ /**
105+ * @return the Oracle service name
106+ */
107+ public String getServiceName () {
108+ return serviceName ;
109+ }
110+
111+ /**
112+ * Set the Oracle service name.
113+ * If set, the client will build an Oracle connection URL in the EZConnect format.
114+ *
115+ * @param serviceName the Oracle service name
116+ * @return a reference to this, so the API can be used fluently
117+ */
118+ public OracleConnectOptions setServiceName (String serviceName ) {
119+ this .serviceName = serviceName ;
120+ return this ;
121+ }
122+
123+ /**
124+ * @return the server connection mode
125+ */
126+ public ServerMode getServerMode () {
127+ return serverMode ;
128+ }
129+
130+ /**
131+ * Set the server connection mode.
132+ *
133+ * @param serverMode the connection mode
134+ * @return a reference to this, so the API can be used fluently
135+ */
136+ public OracleConnectOptions setServerMode (ServerMode serverMode ) {
137+ this .serverMode = serverMode ;
138+ return this ;
139+ }
140+
141+ /**
142+ * @return the Oracle instance name
143+ */
144+ public String getInstanceName () {
145+ return instanceName ;
146+ }
147+
148+ /**
149+ * Set the Oracle instance name.
150+ *
151+ * @param instanceName the instance name
152+ * @return a reference to this, so the API can be used fluently
153+ */
154+ public OracleConnectOptions setInstanceName (String instanceName ) {
155+ this .instanceName = instanceName ;
156+ return this ;
157+ }
158+
71159 public String getTnsAdmin () {
72160 return tnsAdmin ;
73161 }
@@ -124,6 +212,13 @@ public String getDatabase() {
124212 return super .getDatabase ();
125213 }
126214
215+ /**
216+ * Set the database name.
217+ * If set, the client will build an Oracle connection URL in the EZConnect format using the {@code database} value as service name.
218+ *
219+ * @param database the database name to specify
220+ * @return a reference to this, so the API can be used fluently
221+ */
127222 @ Override
128223 public OracleConnectOptions setDatabase (String database ) {
129224 return (OracleConnectOptions ) super .setDatabase (database );
@@ -201,6 +296,15 @@ public JsonObject toJson() {
201296 return json ;
202297 }
203298
299+ @ Override
300+ protected void init () {
301+ this .setHost (DEFAULT_HOST );
302+ this .setPort (DEFAULT_PORT );
303+ this .setUser (DEFAULT_USER );
304+ this .setPassword (DEFAULT_PASSWORD );
305+ this .setDatabase (DEFAULT_DATABASE );
306+ }
307+
204308 @ Override
205309 public OracleConnectOptions merge (JsonObject other ) {
206310 JsonObject json = toJson ();
0 commit comments