OmniSciDB  a667adc9c8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
com.omnisci.jdbc.OmniSciConnection.Connection_properties Class Reference
+ Inheritance diagram for com.omnisci.jdbc.OmniSciConnection.Connection_properties:
+ Collaboration diagram for com.omnisci.jdbc.OmniSciConnection.Connection_properties:

Public Member Functions

 Connection_properties (String connection_url, Properties baseProperties) throws SQLException
 

Package Functions

boolean isHttpProtocol ()
 
boolean isHttpsProtocol_insecure ()
 
boolean isHttpsProtocol ()
 
boolean isBinary ()
 
boolean isBinary_tls ()
 
boolean containsTrustStore ()
 

Private Member Functions

String extract_and_remove_query_components (String connection_url, Properties query_props) throws SQLException
 
void validate_params () throws SQLException
 

Detailed Description

Definition at line 146 of file OmniSciConnection.java.

Constructor & Destructor Documentation

com.omnisci.jdbc.OmniSciConnection.Connection_properties.Connection_properties ( String  connection_url,
Properties  baseProperties 
) throws SQLException
inline

Definition at line 197 of file OmniSciConnection.java.

References com.omnisci.jdbc.OmniSciConnection.Connection_properties.extract_and_remove_query_components(), i, com.omnisci.jdbc.Options.option_order, and com.omnisci.jdbc.OmniSciConnection.Connection_properties.validate_params().

198  {
199  connection_url = extract_and_remove_query_components(connection_url, this);
200  String[] url_values = connection_url.split(":");
201  // add 2 for the default jdbc:omnisci at the start of the url.
202  if (url_values.length > Options.option_order.length + 2) {
203  // would be nice to print the url at this stage, but the user may have added their
204  // password into the list.
205  throw new SQLException("Invalid number of arguments provided in url ["
206  + url_values.length + "]. Maximum allowed ["
207  + (Options.option_order.length + 2) + "]");
208  }
209  for (int i = 2; i < url_values.length; i++) {
210  // the offest of 2 is caused by the 2 lables 'jdbc:omnsci' at the start if the URL
211  String existingValue = getProperty(Options.option_order[i - 2]);
212  if (existingValue != null && !existingValue.equals((url_values[i]))) {
213  logger.warn("Connection property [" + Options.option_order[i - 2]
214  + "] has been provided with different values in the URL and query component of the url. Defaulting to the URL value");
215  }
216  setProperty(Options.option_order[i - 2], url_values[i]);
217  }
218 
219  for (String key : baseProperties.stringPropertyNames()) {
220  String existingValue = getProperty(key);
221  if (existingValue != null
222  && !existingValue.equals(baseProperties.getProperty(key))) {
223  logger.warn("Connection property " + key
224  + "] has been provided with different values in the properties object and the url. Defaulting to the URL value");
225  } else {
226  setProperty(key, baseProperties.getProperty(key));
227  }
228  }
229 
230  validate_params();
231  }
String extract_and_remove_query_components(String connection_url, Properties query_props)

+ Here is the call graph for this function:

Member Function Documentation

boolean com.omnisci.jdbc.OmniSciConnection.Connection_properties.containsTrustStore ( )
inlinepackage

Definition at line 317 of file OmniSciConnection.java.

References com.omnisci.jdbc.Options.server_trust_store.

317  {
318  return this.containsKey(Options.server_trust_store);
319  }
String com.omnisci.jdbc.OmniSciConnection.Connection_properties.extract_and_remove_query_components ( String  connection_url,
Properties  query_props 
) throws SQLException
inlineprivate

Definition at line 169 of file OmniSciConnection.java.

Referenced by com.omnisci.jdbc.OmniSciConnection.Connection_properties.Connection_properties().

170  {
171  // The omnisci version of the connection_url is a ':' separated list
172  // with an optional 'query component' at the end (see example above).
173  // The query component starts with the first '?' in the string.
174  // Its is made up of key=value pairs separated by the '&' character.
175  //
176  // The query component is terminated by the end of the string and is
177  // assumed to be at the end of the URL
178 
179  String[] url_components = connection_url.split("\\?");
180  if (url_components.length == 2) {
181  // Query component are separated by an '&' - replace each with a '\n'
182  // will allow Properties.load method to build a properties obj
183  StringReader reader = new StringReader(url_components[1].replace('&', '\n'));
184  try {
185  query_props.load(reader);
186  } catch (IOException iex) {
187  throw new SQLException(iex.toString());
188  }
189  } else if (url_components.length > 2) {
190  throw new SQLException(
191  "Invalid connection string. Multiple query components included ["
192  + connection_url + "]");
193  }
194  // return the url with out any query component
195  return url_components[0];
196  }

+ Here is the caller graph for this function:

boolean com.omnisci.jdbc.OmniSciConnection.Connection_properties.isBinary ( )
inlinepackage

Definition at line 309 of file OmniSciConnection.java.

References com.omnisci.jdbc.Options.protocol.

Referenced by com.omnisci.jdbc.OmniSciConnection.manageConnection().

309  {
310  return (this.containsKey(Options.protocol)
311  && this.getProperty(Options.protocol).equals("binary"));
312  }

+ Here is the caller graph for this function:

boolean com.omnisci.jdbc.OmniSciConnection.Connection_properties.isBinary_tls ( )
inlinepackage

Definition at line 313 of file OmniSciConnection.java.

References com.omnisci.jdbc.Options.protocol.

Referenced by com.omnisci.jdbc.OmniSciConnection.manageConnection().

313  {
314  return (this.containsKey(Options.protocol)
315  && this.getProperty(Options.protocol).equals("binary_tls"));
316  }

+ Here is the caller graph for this function:

boolean com.omnisci.jdbc.OmniSciConnection.Connection_properties.isHttpProtocol ( )
inlinepackage

Definition at line 294 of file OmniSciConnection.java.

References com.omnisci.jdbc.Options.protocol.

Referenced by com.omnisci.jdbc.OmniSciConnection.manageConnection().

294  {
295  return (this.containsKey(Options.protocol)
296  && this.getProperty(Options.protocol).equals("http"));
297  }

+ Here is the caller graph for this function:

boolean com.omnisci.jdbc.OmniSciConnection.Connection_properties.isHttpsProtocol ( )
inlinepackage

Definition at line 304 of file OmniSciConnection.java.

References com.omnisci.jdbc.Options.protocol.

Referenced by com.omnisci.jdbc.OmniSciConnection.manageConnection().

304  {
305  return (this.containsKey(Options.protocol)
306  && this.getProperty(Options.protocol).equals("https"));
307  }

+ Here is the caller graph for this function:

boolean com.omnisci.jdbc.OmniSciConnection.Connection_properties.isHttpsProtocol_insecure ( )
inlinepackage

Definition at line 299 of file OmniSciConnection.java.

References com.omnisci.jdbc.Options.protocol.

299  {
300  return (this.containsKey(Options.protocol)
301  && this.getProperty(Options.protocol).equals("https_insecure"));
302  }
void com.omnisci.jdbc.OmniSciConnection.Connection_properties.validate_params ( ) throws SQLException
inlineprivate

Definition at line 233 of file OmniSciConnection.java.

References com.omnisci.jdbc.Options.host_name, com.omnisci.jdbc.Options.max_rows, com.omnisci.jdbc.Options.option_order, com.omnisci.jdbc.Options.password, com.omnisci.jdbc.Options.port_num, com.omnisci.jdbc.Options.protocol, com.omnisci.jdbc.OmniSciConnection.protocol_set, com.omnisci.jdbc.Options.server_trust_store, com.omnisci.jdbc.Options.server_trust_store_pwd, and com.omnisci.jdbc.Options.user.

Referenced by com.omnisci.jdbc.OmniSciConnection.Connection_properties.Connection_properties().

233  {
234  // Warn if config values with invalid keys have been used.
235  for (String key : this.stringPropertyNames()) {
236  if (key != Options.user && key != Options.password
237  && !Arrays.asList(Options.option_order).contains(key)) {
238  logger.warn("Unsupported configuration key" + key + " used.");
239  }
240  }
241  // if present remove "//" from front of hostname
242  if (containsKey(Options.host_name)) {
243  String hN = this.getProperty(Options.host_name);
244  if (hN.startsWith("//")) {
245  this.setProperty(Options.host_name, hN.substring(2));
246  }
247  }
248 
249  // Default to binary if no protocol specified
250  String protocol = "binary";
251  if (this.containsKey(Options.protocol)) {
252  protocol = this.getProperty(Options.protocol);
253  protocol.toLowerCase();
254  if (!protocol_set.contains(protocol)) {
255  logger.warn("Incorrect protcol [" + protocol
256  + "] supplied. Possible values are [" + protocol_set.toString()
257  + "]. Using binary as default");
258  protocol = "binary";
259  }
260  }
261  this.setProperty(Options.protocol, protocol);
262 
263  if (this.containsKey(Options.port_num)) {
264  try {
265  Integer.parseInt(getProperty(Options.port_num));
266  } catch (NumberFormatException nfe) {
267  throw new SQLException(
268  "Invalid port number supplied" + getProperty(Options.port_num));
269  }
270  }
271 
272  if (this.containsKey(Options.server_trust_store)
273  && !this.containsKey(Options.server_trust_store_pwd)) {
274  logger.warn("server trust store ["
275  + (String) this.getProperty(Options.server_trust_store)
276  + " specfied without a password");
277  }
278  if (this.containsKey(Options.server_trust_store_pwd)
279  && !this.containsKey(Options.server_trust_store)) {
280  logger.warn("server trust store password specified without a keystore file");
281  }
282  if (!this.containsKey(Options.max_rows)) {
283  this.setProperty(Options.max_rows, "100000");
284  } else {
285  try {
286  Integer.parseInt(getProperty(Options.max_rows));
287  } catch (NumberFormatException nfe) {
288  throw new SQLException(
289  "Invalid value supplied for max rows " + getProperty(Options.max_rows));
290  }
291  }
292  }

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: