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