OmniSciDB  340b00dbf6
 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.nio.file.Files;
35 import java.security.*;
36 import java.security.cert.X509Certificate;
37 import java.security.spec.PKCS8EncodedKeySpec;
38 import java.sql.Array;
39 import java.sql.Blob;
40 import java.sql.CallableStatement;
41 import java.sql.Clob;
42 import java.sql.Connection;
43 import java.sql.DatabaseMetaData;
44 import java.sql.NClob;
45 import java.sql.PreparedStatement;
46 import java.sql.SQLClientInfoException;
47 import java.sql.SQLException;
48 import java.sql.SQLWarning;
49 import java.sql.SQLXML;
50 import java.sql.Savepoint;
51 import java.sql.Statement;
52 import java.sql.Struct;
53 import java.util.*;
54 import java.util.concurrent.Executor;
55 
56 import javax.crypto.Cipher;
57 
58 import sun.security.provider.X509Factory;
63 /*
64  * Param_pair - Simple pair class to hold the label for a component in the url
65  * and an index into the url to that component. For example in the url
66  * jdbc:mapd:hostname:6278 a Param_pair for hostname would have a label of
67  * "hostname" and an index of 2
68  *
69  */
70 class Param_pair {
71  public Param_pair(String l, int i) {
72  label = l;
73  index = i;
74  }
75 
76  public String label;
77  public int index;
78 }
79 
92  user_passwd
93 }
94 
95 class KeyLoader {
96  static class S_struct {
97  public String cert;
98  public Key key;
99  }
100 
101  public static String getX509(X509Certificate cert) throws Exception {
102  String encoded = Base64.getMimeEncoder().encodeToString(cert.getEncoded());
103  // Note mimeEncoder inserts \r\n in the text - the server is okay with that.
104  encoded = X509Factory.BEGIN_CERT + "\n" + encoded + "\n" + X509Factory.END_CERT;
105  return encoded;
106  }
107 
108  public static S_struct getDetails_pkcs12(String filename, String password)
109  throws Exception {
110  S_struct s_struct = new S_struct();
111  try {
112  KeyStore keystore = KeyStore.getInstance("PKCS12");
113  java.io.FileInputStream fis = new java.io.FileInputStream(filename);
114  keystore.load(fis, password.toCharArray());
115  String alias = null;
116  Enumeration<String> eE = keystore.aliases();
117  int count = 0;
118  while (eE.hasMoreElements()) {
119  alias = eE.nextElement();
120  count++;
121  }
122  if (count != 1) {
123  throw new RuntimeException("pkcs12 file [" + filename
124  + "] contains an incorrect number [" + count
125  + "] of certificate(s); only a single certificate is allowed");
126  }
127 
128  X509Certificate cert = (X509Certificate) keystore.getCertificate(alias);
129  s_struct.cert = getX509(cert);
130  s_struct.key = keystore.getKey(alias, password.toCharArray());
131  } catch (Exception eX) {
132  OmniSciConnection.logger.error(eX.getMessage());
133  throw eX;
134  }
135  return s_struct;
136  }
137 }
138 
139 public class OmniSciConnection implements java.sql.Connection, Cloneable {
140  final static Logger logger = LoggerFactory.getLogger(OmniSciConnection.class);
141 
142  Set<String> protocol_set = new HashSet<String>(
143  Arrays.asList("binary", "binary_tls", "http", "https", "https_insecure"));
144  // A simple internal class to hold a summary of the properties passed to the
145  // connection
146  // Properties can come two ways - via the url or via a Properties param
147  class Connection_properties extends Hashtable<Connection_enums, Object> {
148  // All 'used' properties should be listed in this enum map
149  EnumMap<Connection_enums, Param_pair> connection_map =
150  new EnumMap<Connection_enums, Param_pair>(Connection_enums.class) {
151  {
152  // the map allows peoperties to be access via a enum rather than string
153  put(Connection_enums.host_name, new Param_pair("host_name", 2));
154  put(Connection_enums.port_num, new Param_pair("port_num", 3));
155  put(Connection_enums.db_name, new Param_pair("db_name", 4));
156  put(Connection_enums.protocol, new Param_pair("protocol", 5));
158  new Param_pair("server_trust_store", 6));
160  new Param_pair("server_trust_store_pwd", 7));
161  put(Connection_enums.pkiauth, new Param_pair("pkiauth", 7));
162  put(Connection_enums.sslcert, new Param_pair("sslcert", 8));
163  put(Connection_enums.sslkey, new Param_pair("sslkey", 9));
165  new Param_pair("sslkey_password", 10));
166  put(Connection_enums.user, new Param_pair("user", 100));
167  put(Connection_enums.user_passwd, new Param_pair("password", 101));
168  }
169  };
170  protected boolean parm_warning = false;
171 
172  public Connection_properties(Properties properties, String connection_url) {
173  super();
174  String[] url_values = connection_url.split(":");
175 
176  // Look for all possible properties values
177  for (Connection_enums enum_key : connection_map.keySet()) {
178  // Get each entry - a string to index the properties param (such as host_name
179  // and an int to index it into the URL, such as 5 for host_name.
180  // index will be greater than 99 if the value shouldn't be expected in the URL
181  Param_pair param_pair = connection_map.get(enum_key);
182  String value_from_prop = null;
183  String value_from_url = null;
184  // if the index is inside the range of the URL then grab the value
185  if (param_pair.index < url_values.length) {
186  value_from_url = url_values[param_pair.index];
187  }
188 
189  // Grab the possible value from the properties variable, using the already
190  // obtained value_from_url as the default if the entry isn't in properties
191  // (note value_from_url could still be null in which case value_from_prop will
192  // be null)
193  value_from_prop = properties.getProperty(param_pair.label, value_from_url);
194  if (value_from_url != null && value_from_prop != null) {
195  if (!value_from_prop.equals(value_from_url)) {
196  logger.warn("Connected property in url[" + value_from_url
197  + "] differs from Properties class [" + value_from_prop
198  + "]. Using url version");
199  value_from_prop = value_from_url;
200  parm_warning = true;
201  }
202  }
203  if (value_from_prop != null) this.put(enum_key, value_from_prop);
204  }
205  // Make sure we have all that is needed and in the correct format
206  validate_params();
207  }
208 
209  private void validate_params() {
210  // if present remove "//" from front of hostname
211  String hN = (String) this.get(Connection_enums.host_name);
212  if (hN.startsWith("//")) {
213  this.put(Connection_enums.host_name, hN.substring(2));
214  }
215  Integer port_num = Integer.parseInt((String) (this.get(Connection_enums.port_num)));
216  this.put(Connection_enums.port_num, port_num);
217  // Default to binary of no protocol specified
218  String protocol = "binary";
219  if (this.containsKey(Connection_enums.protocol)) {
220  protocol = (String) this.get(Connection_enums.protocol);
221  protocol.toLowerCase();
222  if (!protocol_set.contains(protocol)) {
223  logger.warn("Incorrect protcol [" + protocol
224  + "] supplied. Possible values are [" + protocol_set.toString()
225  + "]. Using binary as default");
226  protocol = "binary";
227  parm_warning = true;
228  }
229  }
230  this.put(Connection_enums.protocol, protocol);
231  if (this.containsKey(Connection_enums.server_trust_store)
232  && !this.containsKey(Connection_enums.server_trust_store_pwd)) {
233  logger.warn("server trust store ["
234  + (String) this.get(Connection_enums.server_trust_store)
235  + " specfied without a password");
236  parm_warning = true;
237  }
238  if (this.containsKey(Connection_enums.server_trust_store_pwd)
239  && !this.containsKey(Connection_enums.server_trust_store)) {
240  logger.warn("server trust store password specified without a keystore file");
241  parm_warning = true;
242  }
243  }
244 
245  boolean isHttpProtocol() {
246  return (this.containsKey(Connection_enums.protocol)
247  && this.get(Connection_enums.protocol).equals("http"));
248  }
249 
251  return (this.containsKey(Connection_enums.protocol)
252  && this.get(Connection_enums.protocol).equals("https_insecure"));
253  }
254 
255  boolean isHttpsProtocol() {
256  return (this.containsKey(Connection_enums.protocol)
257  && this.get(Connection_enums.protocol).equals("https"));
258  }
259 
260  boolean isBinary() {
261  return (this.containsKey(Connection_enums.protocol)
262  && this.get(Connection_enums.protocol).equals("binary"));
263  }
264  boolean isBinary_tls() {
265  return (this.containsKey(Connection_enums.protocol)
266  && this.get(Connection_enums.protocol).equals("binary_tls"));
267  }
268  boolean containsTrustStore() {
269  return this.containsKey(Connection_enums.server_trust_store);
270  }
271  } /*
272  * End class Connection_properties extends Hashtable<Connection_enums, Object>
273  */
274 
275  protected String session = null;
276  protected OmniSci.Client client = null;
277  protected String catalog;
278  protected TTransport transport;
279  protected SQLWarning warnings;
280  protected String url;
281  protected Connection_properties cP = null;
282 
283  public OmniSciConnection getAlternateConnection() throws SQLException {
284  // Clones the orignal java connection object, and then reconnects
285  // at the thrift layer - doesn't re-authenticate at the application
286  // level. Instead reuses the orignal connections session number.
287  logger.debug("OmniSciConnection clone");
288  OmniSciConnection omniSciConnection = null;
289  try {
290  omniSciConnection = (OmniSciConnection) super.clone();
291  } catch (CloneNotSupportedException eE) {
292  throw new SQLException(
293  "Error cloning connection [" + OmniSciExceptionText.getExceptionDetail(eE),
294  eE);
295  }
296  // Now over write the old connection.
297  try {
298  TProtocol protocol = omniSciConnection.manageConnection();
299  omniSciConnection.client = new OmniSci.Client(protocol);
300  } catch (java.lang.Exception jE) {
301  throw new SQLException("Error creating new connection "
303  jE);
304  }
305  return omniSciConnection;
306  }
307 
308  private TProtocol manageConnection() throws java.lang.Exception {
309  SockTransportProperties skT = null;
310  String trust_store = null;
311  if (cP.get(Connection_enums.server_trust_store) != null
312  && !cP.get(Connection_enums.server_trust_store).toString().isEmpty()) {
313  trust_store = cP.get(Connection_enums.server_trust_store).toString();
314  }
315  String trust_store_pwd = null;
317  && !cP.get(Connection_enums.server_trust_store_pwd).toString().isEmpty()) {
318  trust_store_pwd = cP.get(Connection_enums.server_trust_store_pwd).toString();
319  }
320 
321  TProtocol protocol = null;
322  if (this.cP.isHttpProtocol()) {
323  // HTTP
324  skT = SockTransportProperties.getUnencryptedClient();
325 
326  transport = skT.openHttpClientTransport(
327  (String) this.cP.get(Connection_enums.host_name),
328  ((Integer) this.cP.get(Connection_enums.port_num)).intValue());
329  transport.open();
330  protocol = new TJSONProtocol(transport);
331 
332  } else if (this.cP.isBinary()) {
333  skT = SockTransportProperties.getUnencryptedClient();
334  transport =
335  skT.openClientTransport((String) this.cP.get(Connection_enums.host_name),
336  ((Integer) this.cP.get(Connection_enums.port_num)).intValue());
337  if (!transport.isOpen()) transport.open();
338  protocol = new TBinaryProtocol(transport);
339 
340  } else if (this.cP.isHttpsProtocol() || this.cP.isHttpsProtocol_insecure()) {
341  if (trust_store == null) {
342  skT = SockTransportProperties.getEncryptedClientDefaultTrustStore(
343  !this.cP.isHttpsProtocol_insecure());
344  } else {
345  skT = SockTransportProperties.getEncryptedClientSpecifiedTrustStore(
346  trust_store, trust_store_pwd, !this.cP.isHttpsProtocol_insecure());
347  }
348  transport = skT.openHttpsClientTransport(
349  (String) this.cP.get(Connection_enums.host_name),
350  ((Integer) this.cP.get(Connection_enums.port_num)).intValue());
351  transport.open();
352  protocol = new TJSONProtocol(transport);
353 
354  } else if (cP.isBinary_tls()) {
355  if (trust_store == null) {
356  skT = SockTransportProperties.getEncryptedClientDefaultTrustStore(false);
357  } else {
358  skT = SockTransportProperties.getEncryptedClientSpecifiedTrustStore(
359  trust_store, trust_store_pwd, false);
360  }
361  transport =
362  skT.openClientTransport((String) this.cP.get(Connection_enums.host_name),
363  ((Integer) this.cP.get(Connection_enums.port_num)).intValue());
364 
365  if (!transport.isOpen()) transport.open();
366  protocol = new TBinaryProtocol(transport);
367  } else {
368  throw new RuntimeException("Invalid protocol supplied");
369  }
370  return protocol;
371  }
372 
373  private void setSession(Object pki_auth) throws java.lang.Exception {
374  KeyLoader.S_struct s_struct = null;
375  // If pki aut then stuff public cert into password.
376  if (pki_auth != null && pki_auth.toString().equalsIgnoreCase("true")) {
377  s_struct = KeyLoader.getDetails_pkcs12(
378  this.cP.get(Connection_enums.sslcert).toString(),
380  this.cP.put(Connection_enums.user_passwd, s_struct.cert);
381  }
382 
383  // Get the seesion for all connectioms
384  session = client.connect((String) this.cP.get(Connection_enums.user),
385  (String) this.cP.get(Connection_enums.user_passwd),
386  (String) this.cP.get(Connection_enums.db_name));
387 
388  // if pki auth the session will be encoded.
389  if (pki_auth != null && pki_auth.toString().equalsIgnoreCase("true")) {
390  Cipher cipher = Cipher.getInstance(s_struct.key.getAlgorithm());
391  cipher.init(Cipher.DECRYPT_MODE, s_struct.key);
392  // session is encrypted and encoded in b64
393  byte[] decodedBytes = Base64.getDecoder().decode(session);
394  byte[] decoded_bytes = cipher.doFinal(decodedBytes);
395  session = new String(decoded_bytes, "UTF-8");
396  }
397  }
398 
399  public OmniSciConnection(String url, Properties info)
400  throws SQLException { // logger.debug("Entered");
401  this.url = url;
402  this.cP = new Connection_properties(info, url);
403 
404  try {
405  TProtocol protocol = manageConnection();
406  client = new OmniSci.Client(protocol);
408  catalog = (String) this.cP.get(Connection_enums.db_name);
409  } catch (TTransportException ex) {
410  throw new SQLException("Thrift transport connection failed - "
412  ex);
413  } catch (TOmniSciException ex) {
414  throw new SQLException("Omnisci connection failed - "
416  ex);
417  } catch (TException ex) {
418  throw new SQLException(
419  "Thrift failed - " + OmniSciExceptionText.getExceptionDetail(ex), ex);
420  } catch (java.lang.Exception ex) {
421  throw new SQLException(
422  "Connection failed - " + OmniSciExceptionText.getExceptionDetail(ex), ex);
423  }
424  }
425 
426  @Override
427  public Statement createStatement() throws SQLException { // logger.debug("Entered");
428  return new OmniSciStatement(session, this);
429  }
430 
431  @Override
432  public PreparedStatement prepareStatement(String sql)
433  throws SQLException { // logger.debug("Entered");
434  return new OmniSciPreparedStatement(sql, session, client);
435  }
436 
437  @Override
438  public CallableStatement prepareCall(String sql)
439  throws SQLException { // logger.debug("Entered");
440  throw new UnsupportedOperationException("Not supported yet,"
441  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
442  + " class:" + new Throwable().getStackTrace()[0].getClassName()
443  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
444  }
445 
446  @Override
447  public String nativeSQL(String sql) throws SQLException { // logger.debug("Entered");
448  throw new UnsupportedOperationException("Not supported yet,"
449  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
450  + " class:" + new Throwable().getStackTrace()[0].getClassName()
451  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
452  }
453 
454  @Override
455  public void setAutoCommit(boolean autoCommit)
456  throws SQLException { // logger.debug("Entered");
457  // we always autocommit per statement
458  }
459 
460  @Override
461  public boolean getAutoCommit() throws SQLException { // logger.debug("Entered");
462  return true;
463  }
464 
465  @Override
466  public void commit() throws SQLException { // logger.debug("Entered");
467  // noop
468  }
469 
470  @Override
471  public void rollback() throws SQLException { // logger.debug("Entered");
472  throw new UnsupportedOperationException("Not supported yet,"
473  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
474  + " class:" + new Throwable().getStackTrace()[0].getClassName()
475  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
476  }
477 
478  @Override
479  public void close() throws SQLException { // logger.debug("Entered");
480  try {
481  logger.debug("Session at close is " + session);
482  if (session != null) {
483  client.disconnect(session);
484  }
485  closeConnection();
486  } catch (TOmniSciException ex) {
487  throw new SQLException("disconnect failed." + ex.toString());
488  } catch (TException ex) {
489  throw new SQLException("disconnect failed." + ex.toString());
490  }
491  }
492 
493  // needs to be accessed by other classes with in the package
494  protected void closeConnection() throws SQLException { // logger.debug("Entered");
495  session = null;
496  transport.close();
497  }
498 
499  @Override
500  public boolean isClosed() throws SQLException { // logger.debug("Entered");
501  if (session == null) {
502  return true;
503  }
504  return false;
505  }
506 
507  @Override
508  public DatabaseMetaData getMetaData() throws SQLException { // logger.debug("Entered");
509  DatabaseMetaData mapDMetaData = new OmniSciDatabaseMetaData(this);
510 
511  return mapDMetaData;
512  }
513 
514  @Override
515  public void setReadOnly(boolean readOnly)
516  throws SQLException { // logger.debug("Entered");
517  // TODO MAT we can't push the readonly upstream currently
518  // but we could make JDBC obey this command
519  }
520 
521  @Override
522  public boolean isReadOnly() throws SQLException { // logger.debug("Entered");
523  try {
524  if (session != null) {
525  TServerStatus server_status = client.get_server_status(session);
526  return server_status.read_only;
527  }
528  } catch (TOmniSciException ex) {
529  throw new SQLException(
530  "get_server_status failed during isReadOnly check." + ex.toString());
531  } catch (TException ex) {
532  throw new SQLException(
533  "get_server_status failed during isReadOnly check." + ex.toString());
534  }
535  // never should get here
536  return true;
537  }
538 
539  @Override
540  public void setCatalog(String catalog) throws SQLException { // logger.debug("Entered");
541  throw new UnsupportedOperationException("Not supported yet,"
542  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
543  + " class:" + new Throwable().getStackTrace()[0].getClassName()
544  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
545  }
546 
547  @Override
548  public String getCatalog() throws SQLException { // logger.debug("Entered");
549  return catalog;
550  }
551 
552  @Override
553  public void setTransactionIsolation(int level)
554  throws SQLException { // logger.debug("Entered");
555  }
556 
557  @Override
558  public int getTransactionIsolation() throws SQLException { // logger.debug("Entered");
559  return Connection.TRANSACTION_NONE;
560  }
561 
562  @Override
563  public SQLWarning getWarnings() throws SQLException { // logger.debug("Entered");
564  return warnings;
565  }
566 
567  @Override
568  public void clearWarnings() throws SQLException { // logger.debug("Entered");
569  warnings = null;
570  }
571 
572  @Override
573  public Statement createStatement(int resultSetType, int resultSetConcurrency)
574  throws SQLException { // logger.debug("Entered");
575  return new OmniSciStatement(session, this);
576  }
577 
578  @Override
579  public PreparedStatement prepareStatement(
580  String sql, int resultSetType, int resultSetConcurrency)
581  throws SQLException { // logger.debug("Entered");
582  return new OmniSciPreparedStatement(sql, session, client);
583  }
584 
585  @Override
586  public CallableStatement prepareCall(
587  String sql, int resultSetType, int resultSetConcurrency)
588  throws SQLException { // logger.debug("Entered");
589  throw new UnsupportedOperationException("Not supported yet,"
590  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
591  + " class:" + new Throwable().getStackTrace()[0].getClassName()
592  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
593  }
594 
595  @Override
596  public Map<String, Class<?>> getTypeMap()
597  throws SQLException { // logger.debug("Entered");
598  throw new UnsupportedOperationException("Not supported yet,"
599  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
600  + " class:" + new Throwable().getStackTrace()[0].getClassName()
601  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
602  }
603 
604  @Override
605  public void setTypeMap(Map<String, Class<?>> map)
606  throws SQLException { // logger.debug("Entered");
607  throw new UnsupportedOperationException("Not supported yet,"
608  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
609  + " class:" + new Throwable().getStackTrace()[0].getClassName()
610  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
611  }
612 
613  @Override
614  public void setHoldability(int holdability)
615  throws SQLException { // logger.debug("Entered");
616  throw new UnsupportedOperationException("Not supported yet,"
617  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
618  + " class:" + new Throwable().getStackTrace()[0].getClassName()
619  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
620  }
621 
622  @Override
623  public int getHoldability() throws SQLException { // logger.debug("Entered");
624  throw new UnsupportedOperationException("Not supported yet,"
625  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
626  + " class:" + new Throwable().getStackTrace()[0].getClassName()
627  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
628  }
629 
630  @Override
631  public Savepoint setSavepoint() throws SQLException { // logger.debug("Entered");
632  throw new UnsupportedOperationException("Not supported yet,"
633  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
634  + " class:" + new Throwable().getStackTrace()[0].getClassName()
635  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
636  }
637 
638  @Override
639  public Savepoint setSavepoint(String name)
640  throws SQLException { // logger.debug("Entered");
641  throw new UnsupportedOperationException("Not supported yet,"
642  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
643  + " class:" + new Throwable().getStackTrace()[0].getClassName()
644  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
645  }
646 
647  @Override
648  public void rollback(Savepoint savepoint)
649  throws SQLException { // logger.debug("Entered");
650  throw new UnsupportedOperationException("Not supported yet,"
651  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
652  + " class:" + new Throwable().getStackTrace()[0].getClassName()
653  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
654  }
655 
656  @Override
657  public void releaseSavepoint(Savepoint savepoint)
658  throws SQLException { // logger.debug("Entered");
659  throw new UnsupportedOperationException("Not supported yet,"
660  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
661  + " class:" + new Throwable().getStackTrace()[0].getClassName()
662  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
663  }
664 
665  @Override
666  public Statement createStatement(
667  int resultSetType, int resultSetConcurrency, int resultSetHoldability)
668  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 PreparedStatement prepareStatement(String sql,
677  int resultSetType,
678  int resultSetConcurrency,
679  int resultSetHoldability) throws SQLException { // logger.debug("Entered");
680  throw new UnsupportedOperationException("Not supported yet,"
681  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
682  + " class:" + new Throwable().getStackTrace()[0].getClassName()
683  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
684  }
685 
686  @Override
687  public CallableStatement prepareCall(String sql,
688  int resultSetType,
689  int resultSetConcurrency,
690  int resultSetHoldability) throws SQLException { // logger.debug("Entered");
691  throw new UnsupportedOperationException("Not supported yet,"
692  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
693  + " class:" + new Throwable().getStackTrace()[0].getClassName()
694  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
695  }
696 
697  @Override
698  public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
699  throws SQLException { // logger.debug("Entered");
700  throw new UnsupportedOperationException("Not supported yet,"
701  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
702  + " class:" + new Throwable().getStackTrace()[0].getClassName()
703  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
704  }
705 
706  @Override
707  public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
708  throws SQLException { // logger.debug("Entered");
709  throw new UnsupportedOperationException("Not supported yet,"
710  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
711  + " class:" + new Throwable().getStackTrace()[0].getClassName()
712  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
713  }
714 
715  @Override
716  public PreparedStatement prepareStatement(String sql, String[] columnNames)
717  throws SQLException { // logger.debug("Entered");
718  throw new UnsupportedOperationException("Not supported yet,"
719  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
720  + " class:" + new Throwable().getStackTrace()[0].getClassName()
721  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
722  }
723 
724  @Override
725  public Clob createClob() throws SQLException { // logger.debug("Entered");
726  throw new UnsupportedOperationException("Not supported yet,"
727  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
728  + " class:" + new Throwable().getStackTrace()[0].getClassName()
729  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
730  }
731 
732  @Override
733  public Blob createBlob() throws SQLException { // logger.debug("Entered");
734  throw new UnsupportedOperationException("Not supported yet,"
735  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
736  + " class:" + new Throwable().getStackTrace()[0].getClassName()
737  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
738  }
739 
740  @Override
741  public NClob createNClob() throws SQLException { // logger.debug("Entered");
742  throw new UnsupportedOperationException("Not supported yet,"
743  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
744  + " class:" + new Throwable().getStackTrace()[0].getClassName()
745  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
746  }
747 
748  @Override
749  public SQLXML createSQLXML() throws SQLException { // logger.debug("Entered");
750  throw new UnsupportedOperationException("Not supported yet,"
751  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
752  + " class:" + new Throwable().getStackTrace()[0].getClassName()
753  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
754  }
755 
756  @Override
757  public boolean isValid(int timeout) throws SQLException { // logger.debug("Entered");
758  try {
759  client.get_server_status(session);
760  } catch (TTransportException ex) {
761  throw new SQLException("Connection failed - " + ex.toString());
762  } catch (TOmniSciException ex) {
763  throw new SQLException("Connection failed - " + ex.toString());
764  } catch (TException ex) {
765  throw new SQLException("Connection failed - " + ex.toString());
766  }
767  return true;
768  }
769 
770  @Override
771  public void setClientInfo(String name, String value) throws SQLClientInfoException {
772  throw new UnsupportedOperationException("Not supported yet,"
773  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
774  + " class:" + new Throwable().getStackTrace()[0].getClassName()
775  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
776  }
777 
778  @Override
779  public void setClientInfo(Properties properties) throws SQLClientInfoException {
780  throw new UnsupportedOperationException("Not supported yet,"
781  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
782  + " class:" + new Throwable().getStackTrace()[0].getClassName()
783  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
784  }
785 
786  @Override
787  public String getClientInfo(String name)
788  throws SQLException { // logger.debug("Entered");
789  throw new UnsupportedOperationException("Not supported yet,"
790  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
791  + " class:" + new Throwable().getStackTrace()[0].getClassName()
792  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
793  }
794 
795  @Override
796  public Properties getClientInfo() throws SQLException { // logger.debug("Entered");
797  throw new UnsupportedOperationException("Not supported yet,"
798  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
799  + " class:" + new Throwable().getStackTrace()[0].getClassName()
800  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
801  }
802 
803  @Override
804  public Array createArrayOf(String typeName, Object[] elements)
805  throws SQLException { // logger.debug("Entered");
806  TDatumType type;
807  try {
808  type = TDatumType.valueOf(typeName.toUpperCase());
809  } catch (IllegalArgumentException ex) {
810  throw new SQLException("No matching omnisci type for " + typeName);
811  }
812  return new OmniSciArray(type, elements);
813  }
814 
815  @Override
816  public Struct createStruct(String typeName, Object[] attributes)
817  throws SQLException { // logger.debug("Entered");
818  throw new UnsupportedOperationException("Not supported yet,"
819  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
820  + " class:" + new Throwable().getStackTrace()[0].getClassName()
821  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
822  }
823 
824  @Override
825  public void setSchema(String schema) throws SQLException { // logger.debug("Entered");
826  // Setting setSchema to be a NOOP allows integration with third party products
827  // that require a successful call to setSchema to work.
828  Object db_name = this.cP.get(Connection_enums.db_name);
829  if (db_name == null) {
830  throw new RuntimeException("db name not set, "
831  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
832  + " class:" + new Throwable().getStackTrace()[0].getClassName()
833  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
834  }
835  if (!schema.equals(db_name.toString())) {
836  logger.warn("Connected to schema [" + schema + "] differs from db name [" + db_name
837  + "].");
838  }
839  return;
840  }
841 
842  @Override
843  public String getSchema() throws SQLException { // logger.debug("Entered");
844  throw new UnsupportedOperationException("Not supported yet,"
845  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
846  + " class:" + new Throwable().getStackTrace()[0].getClassName()
847  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
848  }
849 
850  @Override
851  public void abort(Executor executor) throws SQLException { // logger.debug("Entered");
852  throw new UnsupportedOperationException("Not supported yet,"
853  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
854  + " class:" + new Throwable().getStackTrace()[0].getClassName()
855  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
856  }
857 
858  @Override
859  public void setNetworkTimeout(Executor executor, int milliseconds)
860  throws SQLException { // logger.debug("Entered");
861  throw new UnsupportedOperationException("Not supported yet,"
862  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
863  + " class:" + new Throwable().getStackTrace()[0].getClassName()
864  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
865  }
866 
867  @Override
868  public int getNetworkTimeout() throws SQLException { // logger.debug("Entered");
869  throw new UnsupportedOperationException("Not supported yet,"
870  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
871  + " class:" + new Throwable().getStackTrace()[0].getClassName()
872  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
873  }
874 
875  @Override
876  public <T> T unwrap(Class<T> iface) throws SQLException { // logger.debug("Entered");
877  throw new UnsupportedOperationException("Not supported yet,"
878  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
879  + " class:" + new Throwable().getStackTrace()[0].getClassName()
880  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
881  }
882 
883  @Override
884  public boolean isWrapperFor(Class<?> iface)
885  throws SQLException { // logger.debug("Entered");
886  throw new UnsupportedOperationException("Not supported yet,"
887  + " line:" + new Throwable().getStackTrace()[0].getLineNumber()
888  + " class:" + new Throwable().getStackTrace()[0].getClassName()
889  + " method:" + new Throwable().getStackTrace()[0].getMethodName());
890  }
891 }
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)
Connection_properties(Properties properties, String connection_url)
std::string toString(const ExtArgumentType &sig_type)
static String getExceptionDetail(Exception ex)
void setAutoCommit(boolean autoCommit)
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)
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)
Struct createStruct(String typeName, Object[] attributes)
void setNetworkTimeout(Executor executor, int milliseconds)
OmniSciConnection(String url, Properties info)
EnumMap< Connection_enums, Param_pair > connection_map
PreparedStatement prepareStatement(String sql, int[] columnIndexes)
string name
Definition: setup.py:35
void setTypeMap(Map< String, Class<?>> map)