OmniSciDB  8fa3bf436f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OmniSciConnection.java
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.omnisci.jdbc;
17 
19 import com.omnisci.thrift.server.OmniSci;
20 import com.omnisci.thrift.server.TDatumType;
21 import com.omnisci.thrift.server.TOmniSciException;
22 import com.omnisci.thrift.server.TServerStatus;
23 
24 import org.apache.thrift.TException;
25 import org.apache.thrift.protocol.TBinaryProtocol;
26 import org.apache.thrift.protocol.TJSONProtocol;
27 import org.apache.thrift.protocol.TProtocol;
28 import org.apache.thrift.transport.TTransport;
29 import org.apache.thrift.transport.TTransportException;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32 
33 import java.io.*;
34 import java.security.*;
35 import java.security.cert.X509Certificate;
36 import java.sql.Array;
37 import java.sql.Blob;
38 import java.sql.CallableStatement;
39 import java.sql.Clob;
40 import java.sql.Connection;
41 import java.sql.DatabaseMetaData;
42 import java.sql.NClob;
43 import java.sql.PreparedStatement;
44 import java.sql.SQLClientInfoException;
45 import java.sql.SQLException;
46 import java.sql.SQLWarning;
47 import java.sql.SQLXML;
48 import java.sql.Savepoint;
49 import java.sql.Statement;
50 import java.sql.Struct;
51 import java.util.*;
52 import java.util.concurrent.Executor;
53 
54 import javax.crypto.Cipher;
55 
56 import sun.security.provider.X509Factory;
62 class KeyLoader {
63  static class S_struct {
64  public String cert;
65  public Key key;
66  }
67 
68  public static String getX509(X509Certificate cert) throws Exception {
69  String encoded = Base64.getMimeEncoder().encodeToString(cert.getEncoded());
70  // Note mimeEncoder inserts \r\n in the text - the server is okay with that.
71  encoded = X509Factory.BEGIN_CERT + "\n" + encoded + "\n" + X509Factory.END_CERT;
72  return encoded;
73  }
74 
75  public static S_struct getDetails_pkcs12(String filename, String password)
76  throws Exception {
77  S_struct s_struct = new S_struct();
78  try {
79  KeyStore keystore = KeyStore.getInstance("PKCS12");
80  java.io.FileInputStream fis = new java.io.FileInputStream(filename);
81  keystore.load(fis, password.toCharArray());
82  String alias = null;
83  Enumeration<String> eE = keystore.aliases();
84  int count = 0;
85  while (eE.hasMoreElements()) {
86  alias = eE.nextElement();
87  count++;
88  }
89  if (count != 1) {
90  throw new SQLException("pkcs12 file [" + filename
91  + "] contains an incorrect number [" + count
92  + "] of certificate(s); only a single certificate is allowed");
93  }
94 
95  X509Certificate cert = (X509Certificate) keystore.getCertificate(alias);
96  s_struct.cert = getX509(cert);
97  s_struct.key = keystore.getKey(alias, password.toCharArray());
98  } catch (Exception eX) {
99  OmniSciConnection.logger.error(eX.getMessage());
100  throw eX;
101  }
102  return s_struct;
103  }
104 }
105 
106 class Options {
107  // The Options class supplies the keys for the
108  // Connection_properties class
109  static String host_name = "host_name";
110  static String port_num = "port_num";
111  static String db_name = "db_name";
112  static String protocol = "protocol";
113  static String server_trust_store = "server_trust_store";
114  static String server_trust_store_pwd = "server_trust_store_pwd";
115  static String pkiauth = "pkiauth";
116  static String sslcert = "sslcert";
117  static String sslkey = "sslkey";
118  static String sslkey_password = "sslkey_password";
119  static String max_rows = "max_rows";
120  static String user = "user";
121  static String password = "password";
122  // The order in the array corresponds to the order the value will appear in the ':'
123  // separated URL. Used to loop over the incoming URL and store in the properties struct
124  // Note user and password are not expected to come via the main body of the url
125  // However they may be supplied in the query string portion.
126 
127  static String[] option_order = {host_name,
128  port_num,
129  db_name,
130  protocol,
133  pkiauth,
134  sslcert,
135  sslkey,
137  max_rows};
138 }
139 
140 public class OmniSciConnection implements java.sql.Connection, Cloneable {
141  final static Logger logger = LoggerFactory.getLogger(OmniSciConnection.class);
142 
143  Set<String> protocol_set = new HashSet<String>(
144  Arrays.asList("binary", "binary_tls", "http", "https", "https_insecure"));
145 
146  class Connection_properties extends Properties {
147  // Properties can come in three ways:
148  // 1. via main part of the url,
149  // 2, via the query string portion of the URL or
150  // 3. via a Properties param
151  //
152  // Example url. Note the first two fields are constants and must be present. '
153  // jdbc:omnisci:localhost:4247:db_name?max_rows=2000&protocol=binary
154  //
155  // Priority is given to the URL data, followed by the query fragment data and
156  // lastly the Properties information
157  //
158  // All connection parameters can be supplied via the main portion of the connection
159  // URL, however as this structure is position dependent the nth argument must be
160  // preceded by the n - 1 arguments. In the case of complex connection strings it is
161  // recommended to use either a properties object or the query string portion of the
162  // URL.
163  //
164  // Note the class java.sql.DriverManager expects the URL to contain three components
165  // the literal string JDBC a 'subprotocol' followed by a 'subname', as in
166  // 'jdbc:omnisci:localhost' For this reason host mame must be supplied in the main
167  // part of the URL and should not be supplied in the query portion.
168 
170  String connection_url, Properties query_props) throws SQLException {
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  }
197  public Connection_properties(String connection_url, Properties baseProperties)
198  throws SQLException {
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  }
232 
233  private void validate_params() throws SQLException {
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  }
293 
294  boolean isHttpProtocol() {
295  return (this.containsKey(Options.protocol)
296  && this.getProperty(Options.protocol).equals("http"));
297  }
298 
300  return (this.containsKey(Options.protocol)
301  && this.getProperty(Options.protocol).equals("https_insecure"));
302  }
303 
304  boolean isHttpsProtocol() {
305  return (this.containsKey(Options.protocol)
306  && this.getProperty(Options.protocol).equals("https"));
307  }
308 
309  boolean isBinary() {
310  return (this.containsKey(Options.protocol)
311  && this.getProperty(Options.protocol).equals("binary"));
312  }
313  boolean isBinary_tls() {
314  return (this.containsKey(Options.protocol)
315  && this.getProperty(Options.protocol).equals("binary_tls"));
316  }
317  boolean containsTrustStore() {
318  return this.containsKey(Options.server_trust_store);
319  }
320  }
321  /*
322  * End class Connection_properties
323  */
324 
325  protected String session = null;
326  protected OmniSci.Client client = null;
327  protected String catalog;
328  protected TTransport transport;
329  protected SQLWarning warnings;
330  protected String url;
331  protected Connection_properties cP = null;
332 
333  public OmniSciConnection getAlternateConnection() throws SQLException {
334  // Clones the orignal java connection object, and then reconnects
335  // at the thrift layer - doesn't re-authenticate at the application
336  // level. Instead reuses the orignal connections session number.
337  logger.debug("OmniSciConnection clone");
338  OmniSciConnection omniSciConnection = null;
339  try {
340  omniSciConnection = (OmniSciConnection) super.clone();
341  } catch (CloneNotSupportedException eE) {
342  throw new SQLException(
343  "Error cloning connection [" + OmniSciExceptionText.getExceptionDetail(eE),
344  eE);
345  }
346  // Now over write the old connection.
347  try {
348  TProtocol protocol = omniSciConnection.manageConnection();
349  omniSciConnection.client = new OmniSci.Client(protocol);
350  } catch (java.lang.Exception jE) {
351  throw new SQLException("Error creating new connection "
353  jE);
354  }
355  return omniSciConnection;
356  }
357 
358  // any java.lang.Exception thrown is caught downstream and converted
359  // to a SQLException
360  private TProtocol manageConnection() throws java.lang.Exception {
361  SockTransportProperties skT = null;
362  String trust_store = null;
363  if (cP.getProperty(Options.server_trust_store) != null
364  && !cP.getProperty(Options.server_trust_store).isEmpty()) {
365  trust_store = cP.getProperty(Options.server_trust_store);
366  }
367  String trust_store_pwd = null;
368  if (cP.getProperty(Options.server_trust_store_pwd) != null
369  && !cP.getProperty(Options.server_trust_store_pwd).isEmpty()) {
370  trust_store_pwd = cP.getProperty(Options.server_trust_store_pwd);
371  }
372 
373  TProtocol protocol = null;
374  if (this.cP.isHttpProtocol()) {
375  // HTTP
376  skT = SockTransportProperties.getUnencryptedClient();
377 
378  transport = skT.openHttpClientTransport(this.cP.getProperty(Options.host_name),
379  Integer.parseInt(this.cP.getProperty(Options.port_num)));
380  transport.open();
381  protocol = new TJSONProtocol(transport);
382 
383  } else if (this.cP.isBinary()) {
384  skT = SockTransportProperties.getUnencryptedClient();
385  transport = skT.openClientTransport(this.cP.getProperty(Options.host_name),
386  Integer.parseInt(this.cP.getProperty(Options.port_num)));
387  if (!transport.isOpen()) transport.open();
388  protocol = new TBinaryProtocol(transport);
389 
390  } else if (this.cP.isHttpsProtocol() || this.cP.isHttpsProtocol_insecure()) {
391  if (trust_store == null) {
392  skT = SockTransportProperties.getEncryptedClientDefaultTrustStore(
393  !this.cP.isHttpsProtocol_insecure());
394  } else {
395  skT = SockTransportProperties.getEncryptedClientSpecifiedTrustStore(
396  trust_store, trust_store_pwd, !this.cP.isHttpsProtocol_insecure());
397  }
398  transport = skT.openHttpsClientTransport(this.cP.getProperty(Options.host_name),
399  Integer.parseInt(this.cP.getProperty(Options.port_num)));
400  transport.open();
401  protocol = new TJSONProtocol(transport);
402 
403  } else if (cP.isBinary_tls()) {
404  if (trust_store == null) {
405  skT = SockTransportProperties.getEncryptedClientDefaultTrustStore(false);
406  } else {
407  skT = SockTransportProperties.getEncryptedClientSpecifiedTrustStore(
408  trust_store, trust_store_pwd, false);
409  }
410  transport = skT.openClientTransport(this.cP.getProperty(Options.host_name),
411  Integer.parseInt(this.cP.getProperty(Options.port_num)));
412 
413  if (!transport.isOpen()) transport.open();
414  protocol = new TBinaryProtocol(transport);
415  } else {
416  throw new SQLException("Invalid protocol supplied");
417  }
418  return protocol;
419  }
420 
421  private void setSession(Object pki_auth) throws java.lang.Exception {
422  KeyLoader.S_struct s_struct = null;
423  // If pki aut then stuff public cert into password.
424  if (pki_auth != null && pki_auth.toString().equalsIgnoreCase("true")) {
425  s_struct = KeyLoader.getDetails_pkcs12(this.cP.getProperty(Options.sslcert),
426  this.cP.getProperty(Options.sslkey_password));
427  this.cP.setProperty(Options.password, s_struct.cert);
428  }
429 
430  // Get the seesion for all connectioms
431  session = client.connect((String) this.cP.getProperty(Options.user),
432  (String) this.cP.getProperty(Options.password),
433  (String) this.cP.getProperty(Options.db_name));
434 
435  // if pki auth the session will be encoded.
436  if (pki_auth != null && pki_auth.toString().equalsIgnoreCase("true")) {
437  Cipher cipher = Cipher.getInstance(s_struct.key.getAlgorithm());
438  cipher.init(Cipher.DECRYPT_MODE, s_struct.key);
439  // session is encrypted and encoded in b64
440  byte[] decodedBytes = Base64.getDecoder().decode(session);
441  byte[] decoded_bytes = cipher.doFinal(decodedBytes);
442  session = new String(decoded_bytes, "UTF-8");
443  }
444  }
445 
446  public OmniSciConnection(String url, Properties base_properties) throws SQLException {
447  this.url = url;
448  this.cP = new Connection_properties(url, base_properties);
449  try {
450  TProtocol protocol = manageConnection();
451  client = new OmniSci.Client(protocol);
452  setSession(this.cP.getProperty(Options.pkiauth));
453  catalog = (String) this.cP.getProperty(Options.db_name);
454  } catch (TTransportException ex) {
455  throw new SQLException("Thrift transport connection failed - "
457  ex);
458  } catch (TOmniSciException ex) {
459  throw new SQLException("Omnisci connection failed - "
461  ex);
462  } catch (TException ex) {
463  throw new SQLException(
464  "Thrift failed - " + OmniSciExceptionText.getExceptionDetail(ex), ex);
465  } catch (java.lang.Exception ex) {
466  throw new SQLException(
467  "Connection failed - " + OmniSciExceptionText.getExceptionDetail(ex), ex);
468  }
469  }
470 
471  @Override
472  public Statement createStatement() throws SQLException { // logger.debug("Entered");
473  return new OmniSciStatement(session, this);
474  }
475 
476  @Override
477  public PreparedStatement prepareStatement(String sql)
478  throws SQLException { // logger.debug("Entered");
479  return new OmniSciPreparedStatement(sql, session, this);
480  }
481 
482  @Override
483  public CallableStatement prepareCall(String sql)
484  throws SQLException { // logger.debug("Entered");
485  throw new UnsupportedOperationException("Not supported yet,"
486  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
487  + " class:" + new Throwable().getStackTrace()[0].getClassName()
488  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
489  }
490 
491  @Override
492  public String nativeSQL(String sql) throws SQLException { // logger.debug("Entered");
493  throw new UnsupportedOperationException("Not supported yet,"
494  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
495  + " class:" + new Throwable().getStackTrace()[0].getClassName()
496  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
497  }
498 
499  @Override
500  public void setAutoCommit(boolean autoCommit)
501  throws SQLException { // logger.debug("Entered");
502  // we always autocommit per statement
503  }
504 
505  @Override
506  public boolean getAutoCommit() throws SQLException { // logger.debug("Entered");
507  return true;
508  }
509 
510  @Override
511  public void commit() throws SQLException { // logger.debug("Entered");
512  // noop
513  }
514 
515  @Override
516  public void rollback() throws SQLException { // logger.debug("Entered");
517  throw new UnsupportedOperationException("Not supported yet,"
518  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
519  + " class:" + new Throwable().getStackTrace()[0].getClassName()
520  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
521  }
522 
523  @Override
524  public void close() throws SQLException { // logger.debug("Entered");
525  try {
526  logger.debug("Session at close is " + session);
527  if (session != null) {
528  client.disconnect(session);
529  }
530  closeConnection();
531  } catch (TOmniSciException ex) {
532  throw new SQLException("disconnect failed." + ex.toString());
533  } catch (TException ex) {
534  throw new SQLException("disconnect failed." + ex.toString());
535  }
536  }
537 
538  // needs to be accessed by other classes with in the package
539  protected void closeConnection() throws SQLException { // logger.debug("Entered");
540  session = null;
541  transport.close();
542  }
543 
544  @Override
545  public boolean isClosed() throws SQLException { // logger.debug("Entered");
546  if (session == null) {
547  return true;
548  }
549  return false;
550  }
551 
552  @Override
553  public DatabaseMetaData getMetaData() throws SQLException { // logger.debug("Entered");
554  DatabaseMetaData mapDMetaData = new OmniSciDatabaseMetaData(this);
555 
556  return mapDMetaData;
557  }
558 
559  @Override
560  public void setReadOnly(boolean readOnly)
561  throws SQLException { // logger.debug("Entered");
562  // TODO MAT we can't push the readonly upstream currently
563  // but we could make JDBC obey this command
564  }
565 
566  @Override
567  public boolean isReadOnly() throws SQLException { // logger.debug("Entered");
568  try {
569  if (session != null) {
570  TServerStatus server_status = client.get_server_status(session);
571  return server_status.read_only;
572  }
573  } catch (TOmniSciException ex) {
574  throw new SQLException(
575  "get_server_status failed during isReadOnly check." + ex.toString());
576  } catch (TException ex) {
577  throw new SQLException(
578  "get_server_status failed during isReadOnly check." + ex.toString());
579  }
580  // never should get here
581  return true;
582  }
583 
584  @Override
585  public void setCatalog(String catalog) throws SQLException { // logger.debug("Entered");
586  throw new UnsupportedOperationException("Not supported yet,"
587  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
588  + " class:" + new Throwable().getStackTrace()[0].getClassName()
589  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
590  }
591 
592  @Override
593  public String getCatalog() throws SQLException { // logger.debug("Entered");
594  return catalog;
595  }
596 
597  @Override
598  public void setTransactionIsolation(int level)
599  throws SQLException { // logger.debug("Entered");
600  }
601 
602  @Override
603  public int getTransactionIsolation() throws SQLException { // logger.debug("Entered");
604  return Connection.TRANSACTION_NONE;
605  }
606 
607  @Override
608  public SQLWarning getWarnings() throws SQLException { // logger.debug("Entered");
609  return warnings;
610  }
611 
612  @Override
613  public void clearWarnings() throws SQLException { // logger.debug("Entered");
614  warnings = null;
615  }
616 
617  @Override
618  public Statement createStatement(int resultSetType, int resultSetConcurrency)
619  throws SQLException { // logger.debug("Entered");
620  return new OmniSciStatement(session, this);
621  }
622 
623  @Override
624  public PreparedStatement prepareStatement(
625  String sql, int resultSetType, int resultSetConcurrency)
626  throws SQLException { // logger.debug("Entered");
627  return new OmniSciPreparedStatement(sql, session, this);
628  }
629 
630  @Override
631  public CallableStatement prepareCall(
632  String sql, int resultSetType, int resultSetConcurrency)
633  throws SQLException { // logger.debug("Entered");
634  throw new UnsupportedOperationException("Not supported yet,"
635  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
636  + " class:" + new Throwable().getStackTrace()[0].getClassName()
637  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
638  }
639 
640  @Override
641  public Map<String, Class<?>> getTypeMap()
642  throws SQLException { // logger.debug("Entered");
643  throw new UnsupportedOperationException("Not supported yet,"
644  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
645  + " class:" + new Throwable().getStackTrace()[0].getClassName()
646  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
647  }
648 
649  @Override
650  public void setTypeMap(Map<String, Class<?>> map)
651  throws SQLException { // logger.debug("Entered");
652  throw new UnsupportedOperationException("Not supported yet,"
653  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
654  + " class:" + new Throwable().getStackTrace()[0].getClassName()
655  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
656  }
657 
658  @Override
659  public void setHoldability(int holdability)
660  throws SQLException { // logger.debug("Entered");
661  throw new UnsupportedOperationException("Not supported yet,"
662  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
663  + " class:" + new Throwable().getStackTrace()[0].getClassName()
664  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
665  }
666 
667  @Override
668  public int getHoldability() throws SQLException { // logger.debug("Entered");
669  throw new UnsupportedOperationException("Not supported yet,"
670  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
671  + " class:" + new Throwable().getStackTrace()[0].getClassName()
672  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
673  }
674 
675  @Override
676  public Savepoint setSavepoint() throws SQLException { // logger.debug("Entered");
677  throw new UnsupportedOperationException("Not supported yet,"
678  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
679  + " class:" + new Throwable().getStackTrace()[0].getClassName()
680  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
681  }
682 
683  @Override
684  public Savepoint setSavepoint(String name)
685  throws SQLException { // logger.debug("Entered");
686  throw new UnsupportedOperationException("Not supported yet,"
687  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
688  + " class:" + new Throwable().getStackTrace()[0].getClassName()
689  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
690  }
691 
692  @Override
693  public void rollback(Savepoint savepoint)
694  throws SQLException { // logger.debug("Entered");
695  throw new UnsupportedOperationException("Not supported yet,"
696  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
697  + " class:" + new Throwable().getStackTrace()[0].getClassName()
698  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
699  }
700 
701  @Override
702  public void releaseSavepoint(Savepoint savepoint)
703  throws SQLException { // logger.debug("Entered");
704  throw new UnsupportedOperationException("Not supported yet,"
705  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
706  + " class:" + new Throwable().getStackTrace()[0].getClassName()
707  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
708  }
709 
710  @Override
711  public Statement createStatement(
712  int resultSetType, int resultSetConcurrency, int resultSetHoldability)
713  throws SQLException { // logger.debug("Entered");
714  throw new UnsupportedOperationException("Not supported yet,"
715  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
716  + " class:" + new Throwable().getStackTrace()[0].getClassName()
717  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
718  }
719 
720  @Override
721  public PreparedStatement prepareStatement(String sql,
722  int resultSetType,
723  int resultSetConcurrency,
724  int resultSetHoldability) throws SQLException { // logger.debug("Entered");
725  throw new UnsupportedOperationException("Not supported yet,"
726  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
727  + " class:" + new Throwable().getStackTrace()[0].getClassName()
728  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
729  }
730 
731  @Override
732  public CallableStatement prepareCall(String sql,
733  int resultSetType,
734  int resultSetConcurrency,
735  int resultSetHoldability) throws SQLException { // logger.debug("Entered");
736  throw new UnsupportedOperationException("Not supported yet,"
737  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
738  + " class:" + new Throwable().getStackTrace()[0].getClassName()
739  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
740  }
741 
742  @Override
743  public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
744  throws SQLException { // logger.debug("Entered");
745  throw new UnsupportedOperationException("Not supported yet,"
746  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
747  + " class:" + new Throwable().getStackTrace()[0].getClassName()
748  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
749  }
750 
751  @Override
752  public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
753  throws SQLException { // logger.debug("Entered");
754  throw new UnsupportedOperationException("Not supported yet,"
755  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
756  + " class:" + new Throwable().getStackTrace()[0].getClassName()
757  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
758  }
759 
760  @Override
761  public PreparedStatement prepareStatement(String sql, String[] columnNames)
762  throws SQLException { // logger.debug("Entered");
763  throw new UnsupportedOperationException("Not supported yet,"
764  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
765  + " class:" + new Throwable().getStackTrace()[0].getClassName()
766  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
767  }
768 
769  @Override
770  public Clob createClob() throws SQLException { // logger.debug("Entered");
771  throw new UnsupportedOperationException("Not supported yet,"
772  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
773  + " class:" + new Throwable().getStackTrace()[0].getClassName()
774  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
775  }
776 
777  @Override
778  public Blob createBlob() throws SQLException { // logger.debug("Entered");
779  throw new UnsupportedOperationException("Not supported yet,"
780  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
781  + " class:" + new Throwable().getStackTrace()[0].getClassName()
782  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
783  }
784 
785  @Override
786  public NClob createNClob() throws SQLException { // logger.debug("Entered");
787  throw new UnsupportedOperationException("Not supported yet,"
788  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
789  + " class:" + new Throwable().getStackTrace()[0].getClassName()
790  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
791  }
792 
793  @Override
794  public SQLXML createSQLXML() throws SQLException { // logger.debug("Entered");
795  throw new UnsupportedOperationException("Not supported yet,"
796  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
797  + " class:" + new Throwable().getStackTrace()[0].getClassName()
798  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
799  }
800 
801  @Override
802  public boolean isValid(int timeout) throws SQLException { // logger.debug("Entered");
803  try {
804  client.get_server_status(session);
805  } catch (TTransportException ex) {
806  throw new SQLException("Connection failed - " + ex.toString());
807  } catch (TOmniSciException ex) {
808  throw new SQLException("Connection failed - " + ex.toString());
809  } catch (TException ex) {
810  throw new SQLException("Connection failed - " + ex.toString());
811  }
812  return true;
813  }
814 
815  @Override
816  public void setClientInfo(String name, String value) throws SQLClientInfoException {
817  throw new UnsupportedOperationException("Not supported yet,"
818  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
819  + " class:" + new Throwable().getStackTrace()[0].getClassName()
820  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
821  }
822 
823  @Override
824  public void setClientInfo(Properties properties) throws SQLClientInfoException {
825  throw new UnsupportedOperationException("Not supported yet,"
826  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
827  + " class:" + new Throwable().getStackTrace()[0].getClassName()
828  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
829  }
830 
831  @Override
832  public String getClientInfo(String name)
833  throws SQLException { // logger.debug("Entered");
834  throw new UnsupportedOperationException("Not supported yet,"
835  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
836  + " class:" + new Throwable().getStackTrace()[0].getClassName()
837  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
838  }
839 
840  @Override
841  public Properties getClientInfo() throws SQLException { // logger.debug("Entered");
842  throw new UnsupportedOperationException("Not supported yet,"
843  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
844  + " class:" + new Throwable().getStackTrace()[0].getClassName()
845  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
846  }
847 
848  @Override
849  public Array createArrayOf(String typeName, Object[] elements)
850  throws SQLException { // logger.debug("Entered");
851  TDatumType type;
852  try {
853  type = TDatumType.valueOf(typeName.toUpperCase());
854  } catch (IllegalArgumentException ex) {
855  throw new SQLException("No matching omnisci type for " + typeName);
856  }
857  return new OmniSciArray(type, elements);
858  }
859 
860  @Override
861  public Struct createStruct(String typeName, Object[] attributes)
862  throws SQLException { // logger.debug("Entered");
863  throw new UnsupportedOperationException("Not supported yet,"
864  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
865  + " class:" + new Throwable().getStackTrace()[0].getClassName()
866  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
867  }
868 
869  @Override
870  public void setSchema(String schema) throws SQLException { // logger.debug("Entered");
871  // Setting setSchema to be a NOOP allows integration with third party products
872  // that require a successful call to setSchema to work.
873  Object db_name = this.cP.getProperty(Options.db_name);
874  if (db_name == null) {
875  throw new SQLException("db name not set, "
876  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
877  + " class:" + new Throwable().getStackTrace()[0].getClassName()
878  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
879  }
880  if (!schema.equals(db_name.toString())) {
881  logger.warn("Connected to schema [" + schema + "] differs from db name [" + db_name
882  + "].");
883  }
884  return;
885  }
886 
887  @Override
888  public String getSchema() throws SQLException { // logger.debug("Entered");
889  throw new UnsupportedOperationException("Not supported yet,"
890  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
891  + " class:" + new Throwable().getStackTrace()[0].getClassName()
892  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
893  }
894 
895  @Override
896  public void abort(Executor executor) throws SQLException { // logger.debug("Entered");
897  throw new UnsupportedOperationException("Not supported yet,"
898  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
899  + " class:" + new Throwable().getStackTrace()[0].getClassName()
900  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
901  }
902 
903  @Override
904  public void setNetworkTimeout(Executor executor, int milliseconds)
905  throws SQLException { // logger.debug("Entered");
906  throw new UnsupportedOperationException("Not supported yet,"
907  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
908  + " class:" + new Throwable().getStackTrace()[0].getClassName()
909  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
910  }
911 
912  @Override
913  public int getNetworkTimeout() throws SQLException { // logger.debug("Entered");
914  throw new UnsupportedOperationException("Not supported yet,"
915  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
916  + " class:" + new Throwable().getStackTrace()[0].getClassName()
917  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
918  }
919 
920  @Override
921  public <T> T unwrap(Class<T> iface) throws SQLException { // logger.debug("Entered");
922  throw new UnsupportedOperationException("Not supported yet,"
923  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
924  + " class:" + new Throwable().getStackTrace()[0].getClassName()
925  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
926  }
927 
928  @Override
929  public boolean isWrapperFor(Class<?> iface)
930  throws SQLException { // logger.debug("Entered");
931  throw new UnsupportedOperationException("Not supported yet,"
932  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
933  + " class:" + new Throwable().getStackTrace()[0].getClassName()
934  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
935  }
936 }
public< T > T unwrap(Class< T > iface)
std::string filename(char const *path)
Definition: Logger.cpp:62
CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
static String getExceptionDetail(Exception ex)
string name
Definition: setup.in.py:72
void setAutoCommit(boolean autoCommit)
OmniSciConnection(String url, Properties base_properties)
static String getX509(X509Certificate cert)
void setClientInfo(String name, String value)
void releaseSavepoint(Savepoint savepoint)
void rollback(Savepoint savepoint)
PreparedStatement prepareStatement(String sql)
CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
Array createArrayOf(String typeName, Object[] elements)
PreparedStatement prepareStatement(String sql, String[] columnNames)
PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
Connection_properties(String connection_url, Properties baseProperties)
int count
static S_struct getDetails_pkcs12(String filename, String password)
void setClientInfo(Properties properties)
Map< String, Class<?> > getTypeMap()
Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
Statement createStatement(int resultSetType, int resultSetConcurrency)
CallableStatement prepareCall(String sql)
String extract_and_remove_query_components(String connection_url, Properties query_props)
std::string typeName(const T *v)
Definition: toString.h:82
Struct createStruct(String typeName, Object[] attributes)
void setNetworkTimeout(Executor executor, int milliseconds)
PreparedStatement prepareStatement(String sql, int[] columnIndexes)
void setTypeMap(Map< String, Class<?>> map)