1 26 27 package org.objectweb.cjdbc.driver; 28 29 import java.io.IOException ; 30 import java.net.Socket ; 31 import java.sql.ResultSet ; 32 import java.sql.SQLException ; 33 import java.sql.SQLWarning ; 34 import java.sql.Savepoint ; 35 import java.util.HashMap ; 36 import java.util.Iterator ; 37 import java.util.Map ; 38 import java.util.Properties ; 39 40 import org.objectweb.cjdbc.common.exceptions.AuthenticationException; 41 import org.objectweb.cjdbc.common.exceptions.NoMoreBackendException; 42 import org.objectweb.cjdbc.common.exceptions.NoMoreControllerException; 43 import org.objectweb.cjdbc.common.exceptions.NotImplementedException; 44 import org.objectweb.cjdbc.common.exceptions.ProtocolException; 45 import org.objectweb.cjdbc.common.exceptions.driver.DriverSQLException; 46 import org.objectweb.cjdbc.common.exceptions.driver.protocol.BackendDriverException; 47 import org.objectweb.cjdbc.common.exceptions.driver.protocol.ControllerCoreException; 48 import org.objectweb.cjdbc.common.exceptions.driver.protocol.SerializableException; 49 import org.objectweb.cjdbc.common.sql.AbstractRequest; 50 import org.objectweb.cjdbc.common.sql.AbstractWriteRequest; 51 import org.objectweb.cjdbc.common.sql.SelectRequest; 52 import org.objectweb.cjdbc.common.sql.StoredProcedure; 53 import org.objectweb.cjdbc.common.sql.filters.AbstractBlobFilter; 54 import org.objectweb.cjdbc.common.stream.CJDBCInputStream; 55 import org.objectweb.cjdbc.common.stream.CJDBCOutputStream; 56 import org.objectweb.cjdbc.common.util.Constants; 57 import org.objectweb.cjdbc.driver.connectpolicy.AbstractControllerConnectPolicy; 58 import org.objectweb.cjdbc.driver.protocol.Commands; 59 import org.objectweb.cjdbc.driver.protocol.SQLDataSerialization; 60 import org.objectweb.cjdbc.driver.protocol.TypeTag; 61 62 79 public class Connection implements java.sql.Connection 80 { 81 82 protected boolean controllerNeedsSqlSkeleton = false; 83 84 85 protected boolean isClosed = false; 86 87 protected String escapeChar = "\'"; 88 89 90 protected ControllerInfo controllerInfo = null; 91 92 94 protected Driver driver = null; 95 96 97 protected Socket socket; 98 99 protected CJDBCInputStream socketInput; 100 101 protected CJDBCOutputStream socketOutput; 102 103 static final String LINE_SEPARATOR = System 105 .getProperty("line.separator"); 106 107 109 110 protected boolean autoCommit = true; 111 112 113 protected boolean readOnly = false; 114 115 116 boolean writeExecutedInTransaction = false; 117 118 119 public static final int DEFAULT_TRANSACTION_ISOLATION_LEVEL = -1; 120 121 protected int isolationLevel = DEFAULT_TRANSACTION_ISOLATION_LEVEL; 122 123 124 protected long transactionId = 0; 125 126 127 protected SQLWarning firstWarning = null; 128 129 130 protected DatabaseMetaData metaData = null; 131 132 133 private final CjdbcUrl cjdbcUrl; 134 135 136 protected String vdbUser = null; 137 protected String vdbPassword = null; 138 139 private AbstractBlobFilter blobFilter; 140 private boolean connectionPooling = true; 141 142 protected boolean escapeBackslash = true; 144 protected boolean escapeSingleQuote = true; 145 146 protected boolean driverProcessed = true; 148 149 protected String preparedStatementBooleanTrue = "'1'"; 151 protected String preparedStatementBooleanFalse = "'0'"; 152 153 private boolean closeSocketOnGC = true; 154 155 159 160 175 176 public Connection(Driver driver, Socket socket, CJDBCInputStream in, 177 CJDBCOutputStream out, CjdbcUrl cjdbcUrl, ControllerInfo controller, 178 String userName, String password) throws AuthenticationException, 179 IOException , ProtocolException 180 { 181 this.driver = driver; 182 this.socket = socket; 183 this.socketInput = in; 184 this.socketOutput = out; 185 this.cjdbcUrl = cjdbcUrl; 186 this.controllerInfo = controller; 187 this.vdbUser = userName; 188 this.vdbPassword = password; 189 190 if (!in.readBoolean()) throw new AuthenticationException(in.readUTF()); 192 193 this.controllerNeedsSqlSkeleton = in.readBoolean(); 194 String sfilter = in.readUTF(); 195 this.blobFilter = AbstractBlobFilter.getBlobFilterInstance(sfilter); 196 197 setUrlParametersOptionsOnConnection(cjdbcUrl); 198 if (cjdbcUrl.isDebugEnabled()) 199 System.out.println("New connection:" + this.toString()); 200 } 201 202 207 private void setUrlParametersOptionsOnConnection(CjdbcUrl cjdbcUrl) 208 { 209 HashMap cjdbcUrlParameters = cjdbcUrl.getParameters(); 210 211 String booleanTrue = (String ) cjdbcUrlParameters 212 .get(Driver.BOOLEAN_TRUE_PROPERTY); 213 if (booleanTrue != null) 214 setPreparedStatementBooleanTrue(booleanTrue); 215 216 String booleanFalse = (String ) cjdbcUrlParameters 217 .get(Driver.BOOLEAN_FALSE_PROPERTY); 218 if (booleanFalse != null) 219 setPreparedStatementBooleanFalse(booleanFalse); 220 221 String escapeBaskslash = (String ) cjdbcUrlParameters 222 .get(Driver.ESCAPE_BACKSLASH_PROPERTY); 223 if (escapeBaskslash != null) 224 setEscapeBackslash(new Boolean (escapeBaskslash).booleanValue()); 225 226 String escapeQuote = (String ) cjdbcUrlParameters 227 .get(Driver.ESCAPE_SINGLE_QUOTE_PROPERTY); 228 if (escapeQuote != null) 229 setEscapeSingleQuote(new Boolean (escapeQuote).booleanValue()); 230 231 String escapeCharacter = (String ) cjdbcUrlParameters 232 .get(Driver.ESCAPE_CHARACTER_PROPERTY); 233 if (escapeCharacter != null) 234 setEscapeChar(escapeCharacter); 235 236 String isDriverProcessed = (String ) cjdbcUrlParameters 237 .get(Driver.DRIVER_PROCESSED_PROPERTY); 238 if (isDriverProcessed != null) 239 setDriverProcessed(Boolean.valueOf(isDriverProcessed).booleanValue()); 240 241 this.connectionPooling = !"false".equals(cjdbcUrlParameters 243 .get(Driver.CONNECTION_POOLING_PROPERTY)); 244 245 if (cjdbcUrl.isDebugEnabled()) 246 { 247 for (Iterator iter = cjdbcUrlParameters.entrySet().iterator(); iter 249 .hasNext();) 250 { 251 Map.Entry e = (Map.Entry ) iter.next(); 252 String param = (String ) e.getKey(); 253 if (!Driver.driverProperties.contains(param)) 254 System.out.println("Unrecognized driver parameter: " + param + " = " 255 + (String ) e.getValue()); 256 } 257 } 258 } 259 260 263 protected void finalize() throws Throwable 264 { 265 if (this.closeSocketOnGC) 266 { 267 Throwable t = null; 268 try 269 { 270 rollback(); 271 } 272 catch (Exception e) 273 { 274 t = e; 275 } 276 try 277 { 278 close(); 279 } 280 catch (Exception e) 281 { 282 t = e; 283 } 284 285 if (t != null) 286 { 287 throw t; 288 } 289 290 } 291 super.finalize(); 292 } 293 294 299 public String getUrl() 300 { 301 return cjdbcUrl.getUrl(); 302 } 303 304 309 public String getUserName() 310 { 311 return vdbUser; 312 } 313 314 319 public String getPassword() 320 { 321 return vdbPassword; 322 } 323 324 329 public ControllerInfo getControllerInfo() 330 { 331 return controllerInfo; 332 } 333 334 338 342 public void clearWarnings() 343 { 344 firstWarning = null; 345 } 346 347 350 private void throwSQLExceptionIfClosed(String message) 351 throws DriverSQLException 352 { 353 if (isClosed) 354 throw new DriverSQLException(message); 355 } 356 357 360 private void throwSQLExceptionIfClosed() throws DriverSQLException 361 { 362 throwSQLExceptionIfClosed("Tried to operate on a closed Connection"); 364 } 365 366 373 public void close() throws DriverSQLException 374 { 375 synchronized (this) { 377 throwSQLExceptionIfClosed(); 378 isClosed = true; 379 385 } 386 387 if (connectionPooling) 388 { try 390 { 391 if (cjdbcUrl.isDebugEnabled()) 392 System.out.println("Resetting connection and adding it to the pool"); 393 autoCommit = true; 394 readOnly = false; 395 socketOutput.writeInt(Commands.Reset); 396 socketOutput.flush(); 397 } 398 catch (IOException e) 399 { 400 throw new DriverSQLException("I/O Error while closing the connection\n" 401 + e.getLocalizedMessage(), e); 402 } 403 404 synchronized (driver.pendingConnectionClosing) 406 { 407 if (!driver.connectionClosingThreadisAlive) 408 { if (cjdbcUrl.isDebugEnabled()) 410 System.out.println("Starting a new connection closing thread"); 411 ConnectionClosingThread t = new ConnectionClosingThread(driver); 412 t.start(); 413 } 414 driver.pendingConnectionClosing.add(this); 416 } 417 } 418 else 419 { try 421 { 422 driver = null; if (socketOutput != null) 426 { 427 if (cjdbcUrl.isDebugEnabled()) 428 System.out.println("Closing connection"); 429 socketOutput.writeInt(Commands.Close); 430 socketOutput.flush(); 431 if (socketInput != null) 432 { receiveBoolean(); 439 socketInput.close(); 440 } 441 socketOutput.close(); 442 } 443 444 if (socket != null) 445 socket.close(); 446 } 447 catch (Exception ignore) 448 { 449 } 450 } 451 } 452 453 464 public synchronized void commit() throws DriverSQLException 465 { 466 throwSQLExceptionIfClosed(); 467 if (autoCommit) 468 throw new DriverSQLException( 469 "Trying to commit a connection in autocommit mode"); 470 471 long firstTransactionId = this.transactionId; 472 try 473 { 474 socketOutput.writeInt(Commands.Commit); 475 socketOutput.flush(); 476 this.transactionId = receiveLong(); 478 writeExecutedInTransaction = false; 479 if (cjdbcUrl.isDebugEnabled()) 480 System.out.println("New transaction " + transactionId 481 + " has been started"); 482 } 483 catch (SerializableException e) 484 { 485 throw new DriverSQLException(e); 486 } 487 catch (IOException e) 488 { 489 throw new DriverSQLException( 490 "I/O Error occured around commit of transaction '" 491 + firstTransactionId + "\n" + e.getLocalizedMessage(), e); 492 } 493 } 494 495 505 public java.sql.Statement createStatement() throws DriverSQLException 506 { 507 throwSQLExceptionIfClosed(); 508 return new Statement(this); 509 } 510 511 521 public java.sql.Statement createStatement(int resultSetType, 522 int resultSetConcurrency) throws SQLException 523 { 524 throwSQLExceptionIfClosed(); 525 Statement s = new Statement(this); 526 s.setResultSetType(resultSetType); 527 s.setResultSetConcurrency(resultSetConcurrency); 528 return s; 529 } 530 531 538 public boolean getAutoCommit() throws DriverSQLException 539 { 540 throwSQLExceptionIfClosed(); 541 return this.autoCommit; 542 } 543 544 553 public java.sql.DatabaseMetaData getMetaData() throws DriverSQLException 554 { 555 throwSQLExceptionIfClosed(); 556 if (metaData == null) 557 { 558 metaData = new DatabaseMetaData(this); 559 } 560 return metaData; 561 } 562 563 570 public synchronized String getCatalog() throws DriverSQLException 571 { 572 throwSQLExceptionIfClosed(); 573 try 574 { 575 socketOutput.writeInt(Commands.ConnectionGetCatalog); 576 socketOutput.flush(); 577 578 if (cjdbcUrl.isDebugEnabled()) 579 System.out.println("Connection.getCatalog"); 580 581 return receiveString(); 582 } 583 catch (SerializableException e) 584 { 585 throw new DriverSQLException(e); 586 } 587 catch (IOException e) 588 { 589 throw wrapIOExceptionInDriverSQLException("getCatalog", e); 590 } 591 } 592 593 599 public synchronized ResultSet getCatalogs() throws DriverSQLException 600 { 601 throwSQLExceptionIfClosed(); 602 String myName = "Connection.getCatalogs"; 603 try 604 { 605 socketOutput.writeInt(Commands.ConnectionGetCatalogs); 606 socketOutput.flush(); 607 608 if (cjdbcUrl.isDebugEnabled()) 609 System.out.println(myName); 610 611 return receiveResultSet(myName); 612 } 613 catch (SerializableException e) 614 { 615 throw new DriverSQLException(e); 616 } 617 catch (IOException e) 618 { 619 throw wrapIOExceptionInDriverSQLException("getCatalogs", e); 620 } 621 } 622 623 protected synchronized java.sql.ResultSet getProcedures(String catalog, 624 String schemaPattern, String procedureNamePattern) 625 throws DriverSQLException 626 { 627 throwSQLExceptionIfClosed(); 628 String myName = "Connection.getProcedures"; 629 try 630 { 631 socketOutput.writeInt(Commands.DatabaseMetaDataGetProcedures); 632 socketOutput.writeUTF(catalog); 633 socketOutput.writeUTF(schemaPattern); 634 socketOutput.writeUTF(procedureNamePattern); 635 socketOutput.flush(); 636 637 if (cjdbcUrl.isDebugEnabled()) 638 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 639 + procedureNamePattern + ")"); 640 641 return receiveResultSet(myName); 642 } 643 catch (SerializableException e) 644 { 645 throw new DriverSQLException(e); 646 } 647 catch (IOException e) 648 { 649 throw wrapIOExceptionInDriverSQLException("getProcedures", e); 650 } 651 } 652 653 protected synchronized java.sql.ResultSet getProcedureColumns(String catalog, 654 String schemaPattern, String procedureNamePattern, 655 String columnNamePattern) throws DriverSQLException 656 { 657 throwSQLExceptionIfClosed(); 658 String myName = "Connection.getProcedureColumns"; 659 try 660 { 661 socketOutput.writeInt(Commands.DatabaseMetaDataGetProcedureColumns); 662 socketOutput.writeUTF(catalog); 663 socketOutput.writeUTF(schemaPattern); 664 socketOutput.writeUTF(procedureNamePattern); 665 socketOutput.writeUTF(columnNamePattern); 666 socketOutput.flush(); 667 668 if (cjdbcUrl.isDebugEnabled()) 669 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 670 + procedureNamePattern + "," + columnNamePattern + ")"); 671 672 return receiveResultSet(myName); 673 } 674 catch (SerializableException e) 675 { 676 throw new DriverSQLException(e); 677 } 678 catch (IOException e) 679 { 680 throw wrapIOExceptionInDriverSQLException("getProcedureColumns", e); 681 } 682 } 683 684 697 public int getTransactionIsolation() throws DriverSQLException 698 { 699 throwSQLExceptionIfClosed(); 700 if (isolationLevel == DEFAULT_TRANSACTION_ISOLATION_LEVEL) 703 return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED; 704 return isolationLevel; 705 } 706 707 713 public java.util.Map getTypeMap() throws SQLException 714 { 715 throw new NotImplementedException("getTypeMap()"); 716 } 717 718 724 public SQLWarning getWarnings() 725 { 726 return firstWarning; 727 } 728 729 736 public boolean isClosed() 737 { 738 return isClosed; 739 } 740 741 748 public boolean isReadOnly() 749 { 750 return readOnly; 751 } 752 753 761 public String nativeSQL(String query) 762 { 763 return query; 764 } 765 766 774 public java.sql.CallableStatement prepareCall(String sql) throws SQLException 775 { 776 throwSQLExceptionIfClosed(); 777 return prepareCall(sql, java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, 778 java.sql.ResultSet.CONCUR_READ_ONLY); 779 } 780 781 790 public java.sql.CallableStatement prepareCall(String sql, int resultSetType, 791 int resultSetConcurrency) throws SQLException 792 { 793 throwSQLExceptionIfClosed(); 794 CallableStatement c = new CallableStatement(this, sql); 795 c.setResultSetType(resultSetType); 796 c.setResultSetConcurrency(resultSetConcurrency); 797 return c; 798 } 799 800 811 public java.sql.PreparedStatement prepareStatement(String sql) 812 throws SQLException 813 { 814 throwSQLExceptionIfClosed(); 815 return new PreparedStatement(this, sql); 816 } 817 818 829 public java.sql.PreparedStatement prepareStatement(String sql, 830 int resultSetType, int resultSetConcurrency) throws SQLException 831 { 832 throwSQLExceptionIfClosed(); 833 PreparedStatement s = new PreparedStatement(this, sql); 834 s.setResultSetType(resultSetType); 835 s.setResultSetConcurrency(resultSetConcurrency); 836 return s; 837 } 838 839 848 public synchronized void rollback() throws DriverSQLException 849 { 850 throwSQLExceptionIfClosed(); 851 if (autoCommit) 852 throw new DriverSQLException( 853 "Trying to rollback a connection in autocommit mode"); 854 855 long initialTransactionId = this.transactionId; 856 try 857 { 858 socketOutput.writeInt(Commands.Rollback); 859 socketOutput.flush(); 860 this.transactionId = receiveLong(); 862 writeExecutedInTransaction = false; 863 864 if (cjdbcUrl.isDebugEnabled()) 865 System.out 866 .println("Transaction " + transactionId + " has been started"); 867 } 868 catch (SerializableException e) 869 { 870 throw new DriverSQLException(e); 871 } 872 catch (IOException e) 873 { 874 throw new DriverSQLException( 875 "I/O Error occured around rollback of transaction '" 876 + initialTransactionId + "\n" + e.getLocalizedMessage(), e); 877 } 878 } 879 880 898 public synchronized void setAutoCommit(boolean autoCommit) 899 throws DriverSQLException 900 { 901 throwSQLExceptionIfClosed(); 902 if (this.autoCommit == autoCommit) 903 return; 904 905 if (autoCommit) 906 { try 908 { 909 if (cjdbcUrl.isDebugEnabled()) 910 System.out.println("Setting connection in autocommit mode"); 911 socketOutput.writeInt(Commands.SetAutoCommit); 912 socketOutput.flush(); 913 914 receiveBoolean(); 915 writeExecutedInTransaction = false; 916 transactionId = 0; 917 this.autoCommit = true; 918 return; 919 920 } 921 catch (SerializableException se) 922 { 923 throw new DriverSQLException(se); 924 } 925 catch (IOException e) 926 { 927 throw new DriverSQLException( 928 "Error while trying to enable autocommit\n" 929 + e.getLocalizedMessage(), e); 930 } 931 } 932 else 933 { try 935 { 936 socketOutput.writeInt(Commands.Begin); 937 socketOutput.flush(); 938 939 transactionId = receiveLong(); 940 this.autoCommit = false; 941 942 if (cjdbcUrl.isDebugEnabled()) 943 System.out.println("Transaction " + transactionId 944 + " has been started"); 945 } 946 catch (SerializableException e) 947 { 948 throw new DriverSQLException(e); 949 } 950 catch (IOException e) 951 { 952 throw new DriverSQLException( 953 "I/O Error while trying to disable autocommit\n" 954 + e.getLocalizedMessage(), e); 955 } 956 } 957 } 958 959 965 public synchronized void setCatalog(String catalog) throws SQLException 966 { 967 throwSQLExceptionIfClosed(); 968 if (catalog == null) 969 throw new DriverSQLException("Invalid Catalog"); 970 cjdbcUrl.setUrl(driver.changeDatabaseName(cjdbcUrl.getUrl(), catalog)); 971 972 try 973 { 974 socketOutput.writeInt(Commands.ConnectionSetCatalog); 975 socketOutput.writeUTF(catalog); 976 socketOutput.flush(); 977 978 if (cjdbcUrl.isDebugEnabled()) 979 System.out.println("Connection.setCatalog(" + catalog + ")"); 980 981 if (!receiveBoolean()) 982 throw new DriverSQLException("Invalid Catalog"); 983 984 } 985 catch (SerializableException e) 986 { 987 throw new DriverSQLException(e); 988 } 989 catch (IOException e) 990 { 991 throw wrapIOExceptionInDriverSQLException("setCatalog", e); 992 } 993 } 994 995 1006 public void setReadOnly(boolean readOnly) throws DriverSQLException 1007 { 1008 throwSQLExceptionIfClosed(); 1009 if ((autoCommit == false) && writeExecutedInTransaction) 1010 throw new DriverSQLException( 1011 "setReadOnly cannot be called in a transaction that has executed write requests."); 1012 1013 this.readOnly = readOnly; 1014 } 1015 1016 1028 public synchronized void setTransactionIsolation(int level) 1029 throws DriverSQLException 1030 { 1031 throwSQLExceptionIfClosed(); 1032 if ((autoCommit == false) && writeExecutedInTransaction) 1039 throw new DriverSQLException( 1040 "setTransactionIsolation cannot be called in a transaction that has executed write requests."); 1041 1042 if (level != isolationLevel) 1043 { if ((level == TRANSACTION_READ_COMMITTED) 1045 || (level == TRANSACTION_READ_UNCOMMITTED) 1046 || (level == TRANSACTION_REPEATABLE_READ) 1047 || (level == TRANSACTION_SERIALIZABLE)) 1048 { 1049 try 1050 { 1051 socketOutput.writeInt(Commands.SetTransactionIsolation); 1052 socketOutput.writeInt(level); 1053 socketOutput.flush(); 1054 1055 if (cjdbcUrl.isDebugEnabled()) 1056 System.out.println("Setting transaction isolation level to " 1057 + level); 1058 1059 receiveBoolean(); 1060 isolationLevel = level; 1062 return; 1063 1064 } 1065 catch (SerializableException e) 1066 { 1067 throw new DriverSQLException(e); 1068 } 1069 catch (IOException ioe) 1070 { 1071 throw new DriverSQLException( 1072 "I/O Error while setting transaction isolation level to " + level 1073 + "\n" + ioe.getLocalizedMessage(), ioe); 1074 } 1075 } 1076 else 1077 throw new DriverSQLException("Invalid transaction isolation level " 1078 + level); 1079 } } 1081 1082 1088 public void setTypeMap(java.util.Map map) throws SQLException 1089 { 1090 throw new NotImplementedException("setTypeMap()"); 1091 } 1092 1093 1096 1097 1102 private void setCloseSocketOnGC(boolean closeSocketOnGC) 1103 { 1104 this.closeSocketOnGC = closeSocketOnGC; 1105 } 1106 1107 1112 private void setConnectionParametersOnRequest(AbstractRequest request) 1113 { 1114 request.setIsAutoCommit(autoCommit); 1115 request.setIsReadOnly(readOnly); 1116 request.setDriverProcessed(driverProcessed); 1117 } 1118 1119 1128 private DriverResultSet receiveResultSet(String callerName) 1129 throws IOException , ProtocolException, SerializableException 1130 { 1131 TypeTag tag = new TypeTag(socketInput); 1132 1133 if (TypeTag.NULL_RESULTSET.equals(tag)) 1134 return null; 1135 1136 if (TypeTag.RESULTSET.equals(tag)) 1137 { 1138 DriverResultSet drs = new DriverResultSet(this); 1139 return drs; 1140 } 1141 1142 if (TypeTag.EXCEPTION.equals(tag)) 1143 throw receiveException(); 1144 1145 throw new ProtocolException(callerName 1146 + ": expected a resultset, received unexpected tag: " + tag); 1147 } 1148 1149 1157 private void procedureOnStream(StoredProcedure proc, boolean isRead) 1158 throws IOException 1159 { 1160 if (!isRead) 1161 writeExecutedInTransaction = true; 1162 1163 proc.sendToStream(socketOutput, this.controllerNeedsSqlSkeleton); 1164 } 1165 1166 1173 private void writeRequestOnStream(AbstractWriteRequest request) 1174 throws IOException 1175 { 1176 if (!autoCommit) 1177 writeExecutedInTransaction = true; 1178 socketOutput.writeInt(org.objectweb.cjdbc.common.sql.RequestType 1179 .getRequestType(request)); 1180 1181 request.sendToStream(socketOutput, this.controllerNeedsSqlSkeleton); 1182 1183 } 1184 1185 1192 private SerializableException receiveException() throws IOException 1193 { 1194 TypeTag exceptionType = new TypeTag(socketInput); 1195 1196 if (TypeTag.BACKEND_EXCEPTION.equals(exceptionType)) 1197 return new BackendDriverException(socketInput); 1198 if (TypeTag.CORE_EXCEPTION.equals(exceptionType)) 1199 return new ControllerCoreException(socketInput); 1200 1201 throw new ProtocolException("received unknown exception type"); 1202 } 1203 1204 1211 private String receiveString() throws IOException , SerializableException 1212 { 1213 TypeTag tag = new TypeTag(socketInput); 1214 if (TypeTag.NOT_EXCEPTION.equals(tag)) 1215 { 1216 String answer = socketInput.readUTF(); 1217 return answer; 1218 } 1219 1220 throw receiveException(); 1221 } 1222 1223 1230 private boolean receiveBoolean() throws IOException , SerializableException 1231 { 1232 TypeTag tag = new TypeTag(socketInput); 1233 if (TypeTag.NOT_EXCEPTION.equals(tag)) 1234 { 1235 boolean answer = socketInput.readBoolean(); 1236 return answer; 1237 } 1238 1239 throw receiveException(); 1240 } 1241 1242 1249 private int receiveInt() throws IOException , SerializableException 1250 { 1251 TypeTag tag = new TypeTag(socketInput); 1252 if (TypeTag.NOT_EXCEPTION.equals(tag)) 1253 { 1254 int answer = socketInput.readInt(); 1255 return answer; 1256 } 1257 1258 throw receiveException(); 1259 } 1260 1261 1268 private long receiveLong() throws IOException , SerializableException 1269 { 1270 TypeTag tag = new TypeTag(socketInput); 1271 if (TypeTag.NOT_EXCEPTION.equals(tag)) 1272 { 1273 long answer = socketInput.readLong(); 1274 return answer; 1275 } 1276 1277 throw receiveException(); 1278 } 1279 1280 1287 private void savepointOnStream(Savepoint savepoint) throws IOException 1288 { 1289 writeExecutedInTransaction = true; 1290 1291 try 1292 { 1293 socketOutput.writeUTF(savepoint.getSavepointName()); 1294 return; 1295 } 1296 catch (SQLException ignore) 1297 { 1298 } 1300 1301 try 1302 { 1303 socketOutput.writeUTF(String.valueOf(savepoint.getSavepointId())); 1304 return; 1305 } 1306 catch (SQLException ignore) 1307 { 1308 } 1310 } 1311 1312 1320 private synchronized void reconnect() throws DriverSQLException 1321 { 1322 try 1324 { 1325 this.socket.close(); 1326 } 1327 catch (IOException ignore) 1328 { 1329 } 1330 try 1331 { 1332 this.socketInput.close(); 1333 } 1334 catch (IOException ignore) 1335 { 1336 } 1337 try 1338 { 1339 this.socketOutput.close(); 1340 } 1341 catch (IOException ignore) 1342 { 1343 } 1344 synchronized (driver.pendingConnectionClosing) 1346 { 1347 if (driver.pendingConnectionClosing.remove(this)) 1348 System.out.println("Warning! Closed call before reconnect"); 1349 } 1350 1351 Connection newconn = null; 1352 Properties properties = new Properties (); 1355 properties.setProperty(Driver.USER_PROPERTY, vdbUser); 1356 properties.setProperty(Driver.PASSWORD_PROPERTY, vdbPassword); 1357 1358 AbstractControllerConnectPolicy controllerConnectPolicy = cjdbcUrl 1359 .getControllerConnectPolicy(); 1360 if (!controllerConnectPolicy.isSuspectedOfFailure(controllerInfo)) 1363 { try 1365 { 1366 newconn = (Connection) driver.connectToController(properties, cjdbcUrl, 1367 controllerInfo); 1368 if (cjdbcUrl.isDebugEnabled()) 1369 System.out.println("Succeeded to reconnect to current controller: " 1370 + controllerInfo); 1371 } 1372 catch (Exception e) 1373 { 1374 if (cjdbcUrl.isDebugEnabled()) 1375 System.out.println("Failed to reconnect to current controller " 1376 + controllerInfo); 1377 newconn = null; controllerConnectPolicy.suspectControllerOfFailure(controllerInfo); 1379 } 1380 } 1381 1382 if (newconn == null) 1383 { 1384 try 1385 { 1386 controllerInfo = controllerConnectPolicy.getController(); 1389 if (cjdbcUrl.isDebugEnabled()) 1390 System.out.println("Trying to reconnect to another controller: " 1391 + controllerInfo); 1392 newconn = (Connection) driver.connectToController(properties, cjdbcUrl, 1393 controllerInfo); 1394 } 1395 catch (AuthenticationException e) 1396 { 1397 String msg = "Warning! Authentication exception received on connection retry, controller configuration might be inconsistent"; 1400 if (cjdbcUrl.isInfoEnabled()) 1401 System.out.println(msg); 1402 throw new DriverSQLException(msg, e); 1403 } 1404 catch (NoMoreControllerException nmc) 1405 { 1406 throw new DriverSQLException(nmc); 1407 } 1408 catch (DriverSQLException e1) 1409 { 1410 String msg = "Failed to reconnect to other controller: " 1412 + controllerInfo; 1413 if (cjdbcUrl.isDebugEnabled()) 1414 System.out.println(msg); 1415 newconn = null; 1416 controllerConnectPolicy.suspectControllerOfFailure(controllerInfo); 1417 throw new DriverSQLException(msg, e1); 1418 } 1419 } 1420 1421 newconn.setCloseSocketOnGC(false); 1423 this.socket = newconn.socket; 1424 this.socketInput = newconn.socketInput; 1425 this.socketOutput = newconn.socketOutput; 1426 this.controllerInfo = newconn.controllerInfo; 1427 this.isClosed = false; 1428 try 1429 { 1430 if (cjdbcUrl.isDebugEnabled()) 1431 System.out.println("Restoring connection state on controller " 1432 + controllerInfo); 1433 socketOutput.writeInt(Commands.RestoreConnectionState); 1434 socketOutput.writeBoolean(autoCommit); 1435 if (!autoCommit) 1436 socketOutput.writeLong(transactionId); 1437 } 1438 catch (IOException e) 1439 { 1440 throw new DriverSQLException("Failed to reconnect to controller\n" 1441 + e.getLocalizedMessage(), e); 1442 } 1443 } 1444 1445 1452 protected synchronized java.sql.ResultSet execReadRequest( 1453 SelectRequest request) throws DriverSQLException 1454 { 1455 throwSQLExceptionIfClosed("Closed connection cannot process request '" 1456 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) + "'"); 1457 1458 try 1459 { 1460 setConnectionParametersOnRequest(request); 1461 socketOutput.writeInt(Commands.ExecReadRequest); 1462 request.sendToStream(socketOutput, this.controllerNeedsSqlSkeleton); 1463 socketOutput.flush(); 1464 if (cjdbcUrl.isDebugEnabled()) 1465 System.out.println("Executing read request " + request); 1466 1467 TypeTag tag = new TypeTag(socketInput); 1468 1469 if (TypeTag.RESULTSET.equals(tag)) 1471 { 1472 try 1473 { 1474 java.sql.ResultSet drs = new DriverResultSet(this); 1475 return drs; 1476 } 1477 catch (ProtocolException e) 1478 { 1479 throw new DriverSQLException( 1480 "Protocol corruption in Connection.execReadRequest" 1481 + " with request " 1482 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH), e); 1483 } 1484 catch (IOException e) 1485 { if (cjdbcUrl.isInfoEnabled()) 1487 System.out.println("IOException occured trying to reconnect (" 1488 + e.getLocalizedMessage() + ")"); 1489 reconnect(); 1490 return execReadRequest(request); 1491 } 1492 } 1493 1494 if (TypeTag.NULL_RESULTSET.equals(tag)) 1495 return null; 1496 1497 if (TypeTag.EXCEPTION.equals(tag)) 1499 { 1500 Exception recvEx = null; 1501 recvEx = receiveException(); 1502 if (recvEx instanceof ControllerCoreException) 1504 recvEx = ((ControllerCoreException) recvEx) 1505 .compatibilityWrapperHack(); 1506 1507 if (recvEx instanceof NoMoreBackendException) 1508 { 1509 if (cjdbcUrl.isInfoEnabled()) 1510 System.out.println("No more backend available on controller"); 1511 try 1512 { 1513 if (cjdbcUrl.getControllerList().length == 1) 1515 throw new DriverSQLException(recvEx); 1516 else 1517 { 1518 reconnect(); 1521 return execReadRequest(request); 1524 } 1525 } 1526 catch (SQLException e1) 1527 { 1528 recvEx = e1; 1530 } 1531 } 1532 else if (recvEx instanceof IOException ) 1533 { 1534 if (cjdbcUrl.isInfoEnabled()) 1535 System.out.println("IOException occured trying to reconnect (" 1536 + ((IOException ) recvEx).getMessage() + ")"); 1537 reconnect(); 1538 return execReadRequest(request); 1541 } 1542 else if (recvEx instanceof BackendDriverException) 1543 { 1544 throw new DriverSQLException((SerializableException) recvEx); 1546 } 1547 } 1548 1549 throw new ProtocolException( 1551 "Protocol corruption in Connection.execReadRequest for request " 1552 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH)); 1553 } 1554 catch (RuntimeException e) 1555 { 1556 e.printStackTrace(); 1557 throw new DriverSQLException( 1558 "Connection.execReadRequest: Error occured while request '" 1559 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) 1560 + "' was processed by C-JDBC Controller", e); 1561 } 1562 catch (IOException e) 1563 { try 1565 { 1566 if (cjdbcUrl.isInfoEnabled()) 1567 System.out.println("IOException occured trying to reconnect (" 1568 + e.getMessage() + ")"); 1569 reconnect(); 1570 return execReadRequest(request); 1571 } 1572 catch (DriverSQLException e1) 1573 { 1574 throw new DriverSQLException( 1575 "Connection lost while executing request '" 1576 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) 1577 + "' and automatic reconnect failed", e1); 1578 } 1579 } 1580 } 1581 1582 1589 protected synchronized int execWriteRequest(AbstractWriteRequest request) 1590 throws DriverSQLException 1591 { 1592 throwSQLExceptionIfClosed("Closed connection cannot process request '" 1593 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) + "'"); 1594 1595 try 1596 { 1597 setConnectionParametersOnRequest(request); 1598 socketOutput.writeInt(Commands.ExecWriteRequest); 1599 writeRequestOnStream(request); 1600 socketOutput.flush(); 1601 if (cjdbcUrl.isDebugEnabled()) 1602 System.out.println("Executing write request " + request); 1603 1604 return receiveInt(); 1605 1606 } 1607 catch (SerializableException se) 1608 { 1609 throw new DriverSQLException(se); 1610 } 1611 catch (IOException e) 1612 { try 1614 { 1615 reconnect(); 1616 return execWriteRequest(request); 1620 } 1621 catch (DriverSQLException e1) 1622 { 1623 throw new DriverSQLException("Connection lost while executing request'" 1624 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) 1625 + "' and automatic reconnect failed (", e1); 1626 } 1627 } 1628 } 1629 1630 1637 protected synchronized ResultSet execWriteRequestWithKeys( 1638 AbstractWriteRequest request) throws DriverSQLException 1639 { 1640 throwSQLExceptionIfClosed("Closed Connection cannot process request '" 1641 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) + "'"); 1642 1643 try 1644 { 1645 setConnectionParametersOnRequest(request); 1646 socketOutput.writeInt(Commands.ExecWriteRequestWithKeys); 1647 writeRequestOnStream(request); 1648 socketOutput.flush(); 1649 if (cjdbcUrl.isDebugEnabled()) 1650 System.out.println("Executing write request with keys: " + request); 1651 1652 Exception recvEx = null; 1653 TypeTag tag = new TypeTag(socketInput); 1654 1655 1661 if (TypeTag.NULL_RESULTSET.equals(tag)) 1662 return null; 1663 1664 if (TypeTag.EXCEPTION.equals(tag)) 1665 recvEx = receiveException(); 1666 if (recvEx instanceof ControllerCoreException) 1668 recvEx = ((ControllerCoreException) recvEx).compatibilityWrapperHack(); 1669 1670 if (recvEx instanceof BackendDriverException) 1671 throw new DriverSQLException(recvEx); 1672 else if (!TypeTag.RESULTSET.equals(tag)) 1673 { 1674 throw new DriverSQLException( 1675 "Connection.execWriteRequestWithKeys: Unexpected response " 1676 + "for request " 1677 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH), 1678 recvEx); 1679 } 1680 else 1681 { 1682 DriverResultSet drs; 1683 try 1684 { 1685 drs = new DriverResultSet(this); 1686 } 1687 catch (IOException e) 1688 { 1689 throw new DriverSQLException( 1690 "Connection.execWriteRequestWithKeys: IOException " 1691 + e.getLocalizedMessage() 1692 + " while reading keys RS for request " 1693 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH), e); 1694 } 1695 return drs; 1696 } 1697 1698 } 1699 catch (IOException e) 1700 { try 1702 { 1703 reconnect(); 1704 return execWriteRequestWithKeys(request); 1707 } 1708 catch (DriverSQLException e1) 1709 { 1710 throw new DriverSQLException("Connection lost while executing request'" 1711 + request.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) 1712 + "' and automatic reconnect failed", e1); 1713 } 1714 } 1715 } 1716 1717 1724 public synchronized ResultSet execReadStoredProcedure(StoredProcedure proc) 1725 throws DriverSQLException 1726 { 1727 throwSQLExceptionIfClosed("Closed Connection cannot process request '" 1728 + proc.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) + "'"); 1729 1730 try 1731 { 1732 setConnectionParametersOnRequest(proc); 1733 socketOutput.writeInt(Commands.ExecReadStoredProcedure); 1734 procedureOnStream(proc, true); 1735 socketOutput.flush(); 1736 if (cjdbcUrl.isDebugEnabled()) 1737 System.out.println("Executing read stored procedure " + proc); 1738 1739 Exception recvEx = null; 1740 TypeTag tag = new TypeTag(socketInput); 1741 1742 1748 if (TypeTag.NULL_RESULTSET.equals(tag)) 1749 return null; 1750 1751 if (TypeTag.EXCEPTION.equals(tag)) 1752 recvEx = receiveException(); 1753 if (recvEx instanceof ControllerCoreException) 1755 recvEx = ((ControllerCoreException) recvEx).compatibilityWrapperHack(); 1756 1757 if (recvEx instanceof BackendDriverException) 1758 throw new DriverSQLException(recvEx); 1759 else if (!TypeTag.RESULTSET.equals(tag)) 1760 throw new DriverSQLException( 1761 "Connection.execReadStoredProcedure: Unexpected response " 1762 + " for request " 1763 + proc.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH), recvEx); 1764 else 1765 { 1766 DriverResultSet drs; 1767 try 1768 { 1769 drs = new DriverResultSet(this); 1770 } 1771 catch (IOException e) 1772 { 1773 throw new DriverSQLException( 1774 "Connection.execReadStoredProcedure: IOException " 1775 + "while receiving RS for request " 1776 + proc.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH), e); 1777 } 1778 return drs; 1779 } 1780 } 1781 catch (RuntimeException e) 1782 { 1783 throw new DriverSQLException( 1784 "Connection.execReadStoredProcedure: Error occured while request '" 1785 + proc.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) 1786 + "' was processed by C-JDBC Controller", e); 1787 } 1788 catch (IOException e) 1789 { try 1791 { 1792 reconnect(); 1793 return execReadStoredProcedure(proc); 1796 } 1797 catch (DriverSQLException e1) 1798 { 1799 throw new DriverSQLException("Connection lost while executing request'" 1800 + proc.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) 1801 + "' and automatic reconnect failed ", e1); 1802 } 1803 } 1804 } 1805 1806 1813 protected synchronized int execWriteStoredProcedure(StoredProcedure proc) 1814 throws DriverSQLException 1815 { 1816 throwSQLExceptionIfClosed("Closed Connection cannot process request '" 1817 + proc.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) + "'"); 1818 1819 try 1820 { 1821 setConnectionParametersOnRequest(proc); 1822 socketOutput.writeInt(Commands.ExecWriteStoredProcedure); 1823 procedureOnStream(proc, false); 1824 socketOutput.flush(); 1825 if (cjdbcUrl.isDebugEnabled()) 1826 System.out.println("Executing write stored procedure " + proc); 1827 1828 return receiveInt(); 1829 1830 } 1831 catch (SerializableException se) 1832 { 1833 throw new DriverSQLException(se); 1834 } 1835 catch (IOException e) 1836 { 1837 throw new DriverSQLException( 1838 "execWriteStoredProcedure: I/O Error occured while request '" 1839 + proc.getSQLShortForm(Constants.SQL_SHORT_FORM_LENGTH) 1840 + "' was processed by C-JDBC Controller (", e); 1841 } 1842 } 1843 1844 1847 AbstractBlobFilter getBlobFilter() 1848 { 1849 return blobFilter; 1850 } 1851 1852 1856 1860 protected synchronized ResultSet getAttributes(String catalog, 1861 String schemaPattern, String typeNamePattern, String attributeNamePattern) 1862 throws DriverSQLException 1863 { 1864 throwSQLExceptionIfClosed(); 1865 String myName = "Connection.getAttributes"; 1866 try 1867 { 1868 socketOutput.writeInt(Commands.DatabaseMetaDataGetAttributes); 1869 socketOutput.writeUTF(catalog); 1870 socketOutput.writeUTF(schemaPattern); 1871 socketOutput.writeUTF(typeNamePattern); 1872 socketOutput.writeUTF(attributeNamePattern); 1873 socketOutput.flush(); 1874 1875 if (cjdbcUrl.isDebugEnabled()) 1876 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 1877 + typeNamePattern + "," + attributeNamePattern + ")"); 1878 1879 return receiveResultSet(myName); 1880 } 1881 catch (SerializableException e) 1882 { 1883 throw new DriverSQLException(e); 1884 } 1885 catch (IOException e) 1886 { 1887 throw wrapIOExceptionInDriverSQLException("getAttributes", e); 1888 } 1889 } 1890 1891 1895 protected synchronized ResultSet getBestRowIdentifier(String catalog, 1896 String schema, String table, int scope, boolean nullable) 1897 throws DriverSQLException 1898 { 1899 throwSQLExceptionIfClosed(); 1900 String myName = "Connection.getBestRowIdentifier"; 1901 try 1902 { 1903 socketOutput.writeInt(Commands.DatabaseMetaDataGetBestRowIdentifier); 1904 socketOutput.writeUTF(catalog); 1905 socketOutput.writeUTF(schema); 1906 socketOutput.writeUTF(table); 1907 socketOutput.writeInt(scope); 1908 socketOutput.writeBoolean(nullable); 1909 socketOutput.flush(); 1910 1911 if (cjdbcUrl.isDebugEnabled()) 1912 System.out.println(myName + "(" + catalog + "," + schema + "," + table 1913 + "," + scope + "," + nullable + ")"); 1914 1915 return receiveResultSet(myName); 1916 } 1917 catch (SerializableException e) 1918 { 1919 throw new DriverSQLException(e); 1920 } 1921 catch (IOException e) 1922 { 1923 throw wrapIOExceptionInDriverSQLException("getBestRowIdentifier", e); 1924 } 1925 } 1926 1927 1931 protected synchronized ResultSet getColumnPrivileges(String catalog, 1932 String schemaPattern, String tableName, String columnNamePattern) 1933 throws DriverSQLException 1934 { 1935 throwSQLExceptionIfClosed(); 1936 String myName = "Connection.getColumnPrivileges"; 1937 try 1938 { 1939 socketOutput.writeInt(Commands.DatabaseMetaDataGetColumnPrivileges); 1940 socketOutput.writeUTF(catalog); 1941 socketOutput.writeUTF(schemaPattern); 1942 socketOutput.writeUTF(tableName); 1943 socketOutput.writeUTF(columnNamePattern); 1944 socketOutput.flush(); 1945 1946 if (cjdbcUrl.isDebugEnabled()) 1947 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 1948 + tableName + "," + columnNamePattern + ")"); 1949 1950 return receiveResultSet(myName); 1951 } 1952 catch (SerializableException e) 1953 { 1954 throw new DriverSQLException(e); 1955 } 1956 catch (IOException e) 1957 { 1958 throw wrapIOExceptionInDriverSQLException("getColumnPrivileges", e); 1959 } 1960 } 1961 1962 1966 protected synchronized ResultSet getColumns(String catalog, 1967 String schemaPattern, String tableNamePattern, String columnNamePattern) 1968 throws DriverSQLException 1969 { 1970 throwSQLExceptionIfClosed(); 1971 String myName = "Connection.getColumns"; 1972 try 1973 { 1974 socketOutput.writeInt(Commands.DatabaseMetaDataGetColumns); 1975 socketOutput.writeUTF(catalog); 1976 socketOutput.writeUTF(schemaPattern); 1977 socketOutput.writeUTF(tableNamePattern); 1978 socketOutput.writeUTF(columnNamePattern); 1979 socketOutput.flush(); 1980 1981 if (cjdbcUrl.isDebugEnabled()) 1982 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 1983 + tableNamePattern + "," + columnNamePattern + ")"); 1984 1985 return receiveResultSet(myName); 1986 } 1987 catch (SerializableException e) 1988 { 1989 throw new DriverSQLException(e); 1990 } 1991 catch (IOException e) 1992 { 1993 throw wrapIOExceptionInDriverSQLException("getColumns", e); 1994 } 1995 } 1996 1997 2002 protected synchronized ResultSet getCrossReference(String primaryCatalog, 2003 String primarySchema, String primaryTable, String foreignCatalog, 2004 String foreignSchema, String foreignTable) throws DriverSQLException 2005 { 2006 throwSQLExceptionIfClosed(); 2007 String myName = "Connection.getCrossReference"; 2008 try 2009 { 2010 socketOutput.writeInt(Commands.DatabaseMetaDataGetCrossReference); 2011 socketOutput.writeUTF(primaryCatalog); 2012 socketOutput.writeUTF(primarySchema); 2013 socketOutput.writeUTF(primaryTable); 2014 socketOutput.writeUTF(foreignCatalog); 2015 socketOutput.writeUTF(foreignSchema); 2016 socketOutput.writeUTF(foreignTable); 2017 socketOutput.flush(); 2018 2019 if (cjdbcUrl.isDebugEnabled()) 2020 System.out.println(myName + "(" + primaryCatalog + "," + primarySchema 2021 + "," + primaryTable + "," + foreignCatalog + "," + foreignSchema 2022 + "," + foreignTable + ")"); 2023 2024 return receiveResultSet(myName); 2025 } 2026 catch (SerializableException e) 2027 { 2028 throw new DriverSQLException(e); 2029 } 2030 catch (IOException e) 2031 { 2032 throw wrapIOExceptionInDriverSQLException("getCrossReference", e); 2033 } 2034 } 2035 2036 2040 public ResultSet getExportedKeys(String catalog, String schema, String table) 2041 throws DriverSQLException 2042 { 2043 throwSQLExceptionIfClosed(); 2044 String myName = "Connection.getExportedKeys"; 2045 try 2046 { 2047 socketOutput.writeInt(Commands.DatabaseMetaDataGetExportedKeys); 2048 socketOutput.writeUTF(catalog); 2049 socketOutput.writeUTF(schema); 2050 socketOutput.writeUTF(table); 2051 socketOutput.flush(); 2052 2053 if (cjdbcUrl.isDebugEnabled()) 2054 System.out.println(myName + "(" + catalog + "," + schema + "," + table 2055 + ")"); 2056 2057 return receiveResultSet(myName); 2058 } 2059 catch (SerializableException e) 2060 { 2061 throw new DriverSQLException(e); 2062 } 2063 catch (IOException e) 2064 { 2065 throw wrapIOExceptionInDriverSQLException("getExportedKeys", e); 2066 } 2067 } 2068 2069 2073 protected synchronized ResultSet getImportedKeys(String catalog, 2074 String schema, String table) throws DriverSQLException 2075 { 2076 throwSQLExceptionIfClosed(); 2077 String myName = "Connection.getImportedKeys"; 2078 try 2079 { 2080 socketOutput.writeInt(Commands.DatabaseMetaDataGetImportedKeys); 2081 socketOutput.writeUTF(catalog); 2082 socketOutput.writeUTF(schema); 2083 socketOutput.writeUTF(table); 2084 socketOutput.flush(); 2085 2086 if (cjdbcUrl.isDebugEnabled()) 2087 System.out.println(myName + "(" + catalog + "," + schema + "," + table 2088 + ")"); 2089 2090 return receiveResultSet(myName); 2091 } 2092 catch (SerializableException e) 2093 { 2094 throw new DriverSQLException(e); 2095 } 2096 catch (IOException e) 2097 { 2098 throw wrapIOExceptionInDriverSQLException("getImportedKeys", e); 2099 } 2100 } 2101 2102 2106 protected synchronized ResultSet getIndexInfo(String catalog, String schema, 2107 String table, boolean unique, boolean approximate) 2108 throws DriverSQLException 2109 { 2110 throwSQLExceptionIfClosed(); 2111 String myName = "Connection.getIndexInfo"; 2112 try 2113 { 2114 socketOutput.writeInt(Commands.DatabaseMetaDataGetIndexInfo); 2115 socketOutput.writeUTF(catalog); 2116 socketOutput.writeUTF(schema); 2117 socketOutput.writeUTF(table); 2118 socketOutput.writeBoolean(unique); 2119 socketOutput.writeBoolean(approximate); 2120 socketOutput.flush(); 2121 2122 if (cjdbcUrl.isDebugEnabled()) 2123 System.out.println(myName + "(" + catalog + "," + schema + "," + table 2124 + "," + unique + "," + approximate + ")"); 2125 2126 return receiveResultSet(myName); 2127 } 2128 catch (SerializableException e) 2129 { 2130 throw new DriverSQLException(e); 2131 } 2132 catch (IOException e) 2133 { 2134 throw wrapIOExceptionInDriverSQLException("getIndexInfo", e); 2135 } 2136 } 2137 2138 2142 protected synchronized ResultSet getPrimaryKeys(String catalog, 2143 String schemaPattern, String tableNamePattern) throws DriverSQLException 2144 { 2145 throwSQLExceptionIfClosed(); 2146 String myName = "Connection.getPrimaryKeys"; 2147 try 2148 { 2149 socketOutput.writeInt(Commands.DatabaseMetaDataGetPrimaryKeys); 2150 socketOutput.writeUTF(catalog); 2151 socketOutput.writeUTF(schemaPattern); 2152 socketOutput.writeUTF(tableNamePattern); 2153 socketOutput.flush(); 2154 2155 if (cjdbcUrl.isDebugEnabled()) 2156 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 2157 + tableNamePattern + ")"); 2158 2159 return receiveResultSet(myName); 2160 } 2161 catch (SerializableException e) 2162 { 2163 throw new DriverSQLException(e); 2164 } 2165 catch (IOException e) 2166 { 2167 throw wrapIOExceptionInDriverSQLException("getPrimaryKeys", e); 2168 } 2169 } 2170 2171 2175 protected synchronized ResultSet getSuperTables(String catalog, 2176 String schemaPattern, String tableNamePattern) throws DriverSQLException 2177 { 2178 throwSQLExceptionIfClosed(); 2179 String myName = "Connection.getSuperTables"; 2180 try 2181 { 2182 socketOutput.writeInt(Commands.DatabaseMetaDataGetSuperTables); 2183 socketOutput.writeUTF(catalog); 2184 socketOutput.writeUTF(schemaPattern); 2185 socketOutput.writeUTF(tableNamePattern); 2186 socketOutput.flush(); 2187 2188 if (cjdbcUrl.isDebugEnabled()) 2189 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 2190 + tableNamePattern + ")"); 2191 2192 return receiveResultSet(myName); 2193 } 2194 catch (SerializableException e) 2195 { 2196 throw new DriverSQLException(e); 2197 } 2198 catch (IOException e) 2199 { 2200 throw wrapIOExceptionInDriverSQLException("getSuperTables", e); 2201 } 2202 } 2203 2204 2208 protected synchronized ResultSet getSuperTypes(String catalog, 2209 String schemaPattern, String typeNamePattern) throws DriverSQLException 2210 { 2211 throwSQLExceptionIfClosed(); 2212 String myName = "Connection.getSuperTypes"; 2213 try 2214 { 2215 socketOutput.writeInt(Commands.DatabaseMetaDataGetSuperTypes); 2216 socketOutput.writeUTF(catalog); 2217 socketOutput.writeUTF(schemaPattern); 2218 socketOutput.writeUTF(typeNamePattern); 2219 socketOutput.flush(); 2220 2221 if (cjdbcUrl.isDebugEnabled()) 2222 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 2223 + typeNamePattern + ")"); 2224 2225 return receiveResultSet(myName); 2226 } 2227 catch (SerializableException e) 2228 { 2229 throw new DriverSQLException(e); 2230 } 2231 catch (IOException e) 2232 { 2233 throw wrapIOExceptionInDriverSQLException("getSuperTypes", e); 2234 } 2235 } 2236 2237 2241 protected synchronized ResultSet getTables(String catalog, 2242 String schemaPattern, String tableNamePattern, String [] types) 2243 throws DriverSQLException 2244 { 2245 throwSQLExceptionIfClosed(); 2246 String myName = "Connection.getTables"; 2247 try 2248 { 2249 socketOutput.writeInt(Commands.DatabaseMetaDataGetTables); 2250 socketOutput.writeUTF(catalog); 2251 socketOutput.writeUTF(schemaPattern); 2252 socketOutput.writeUTF(tableNamePattern); 2253 2254 if (null == types) 2255 socketOutput.writeBoolean(false); 2256 else 2257 { 2258 socketOutput.writeBoolean(true); 2259 socketOutput.writeInt(types.length); 2260 for (int i = 0; i < types.length; i++) 2261 socketOutput.writeUTF(types[i]); 2262 } 2263 socketOutput.flush(); 2264 2265 if (cjdbcUrl.isDebugEnabled()) 2266 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 2267 + tableNamePattern + "," + types + ")"); 2268 2269 return receiveResultSet(myName); 2270 } 2271 catch (SerializableException e) 2272 { 2273 throw new DriverSQLException(e); 2274 } 2275 catch (IOException e) 2276 { 2277 throw wrapIOExceptionInDriverSQLException("getTables", e); 2278 } 2279 } 2280 2281 2284 protected synchronized ResultSet getTypeInfo() throws DriverSQLException 2285 { 2286 throwSQLExceptionIfClosed(); 2287 String myName = "Connection.getTypeInfo"; 2288 try 2289 { 2290 socketOutput.writeInt(Commands.DatabaseMetaDataGetTypeInfo); 2291 socketOutput.flush(); 2292 2293 if (cjdbcUrl.isDebugEnabled()) 2294 System.out.println(myName + "()"); 2295 2296 return receiveResultSet(myName); 2297 } 2298 catch (SerializableException e) 2299 { 2300 throw new DriverSQLException(e); 2301 } 2302 catch (IOException e) 2303 { 2304 throw wrapIOExceptionInDriverSQLException("getTypeInfo", e); 2305 } 2306 } 2307 2308 2312 protected synchronized ResultSet getUDTs(String catalog, 2313 String schemaPattern, String typeNamePattern, int[] types) 2314 throws DriverSQLException 2315 { 2316 throwSQLExceptionIfClosed(); 2317 String myName = "Connection.getUDTs"; 2318 try 2319 { 2320 socketOutput.writeInt(Commands.DatabaseMetaDataGetUDTs); 2321 socketOutput.writeUTF(catalog); 2322 socketOutput.writeUTF(schemaPattern); 2323 socketOutput.writeUTF(typeNamePattern); 2324 2325 if (null == types) 2326 socketOutput.writeBoolean(false); 2327 else 2328 { 2329 socketOutput.writeBoolean(true); 2330 socketOutput.writeInt(types.length); 2331 for (int i = 0; i < types.length; i++) 2332 socketOutput.writeInt(types[i]); 2333 } 2334 socketOutput.flush(); 2335 2336 if (cjdbcUrl.isDebugEnabled()) 2337 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 2338 + typeNamePattern + "," + types + ")"); 2339 2340 return receiveResultSet(myName); 2341 } 2342 catch (SerializableException e) 2343 { 2344 throw new DriverSQLException(e); 2345 } 2346 catch (IOException e) 2347 { 2348 throw wrapIOExceptionInDriverSQLException("getUDTs", e); 2349 } 2350 } 2351 2352 2356 public synchronized ResultSet getVersionColumns(String catalog, 2357 String schema, String table) throws DriverSQLException 2358 { 2359 throwSQLExceptionIfClosed(); 2360 String myName = "Connection.getVersionColumns"; 2361 try 2362 { 2363 socketOutput.writeInt(Commands.DatabaseMetaDataGetVersionColumns); 2364 socketOutput.writeUTF(catalog); 2365 socketOutput.writeUTF(schema); 2366 socketOutput.writeUTF(table); 2367 socketOutput.flush(); 2368 2369 if (cjdbcUrl.isDebugEnabled()) 2370 System.out.println(myName + "(" + catalog + "," + schema + "," + table 2371 + ")"); 2372 2373 return receiveResultSet(myName); 2374 } 2375 catch (SerializableException e) 2376 { 2377 throw new DriverSQLException(e); 2378 } 2379 catch (IOException e) 2380 { 2381 throw wrapIOExceptionInDriverSQLException("getVersionColumns", e); 2382 } 2383 } 2384 2385 2395 synchronized Object getStaticMetadata(String key) throws DriverSQLException 2396 { 2397 throwSQLExceptionIfClosed(); 2398 try 2399 { 2400 socketOutput.writeInt(Commands.DatabaseStaticMetadata); 2401 socketOutput.writeUTF(key); 2402 socketOutput.flush(); 2403 if (cjdbcUrl.isDebugEnabled()) 2404 System.out.println("Getting " + key + " metadata"); 2405 2406 TypeTag tag = new TypeTag(socketInput); 2407 2408 if (TypeTag.EXCEPTION.equals(tag)) 2409 throw new DriverSQLException(receiveException()); 2410 else 2411 { 2412 tag = new TypeTag(socketInput); 2413 Object result = SQLDataSerialization.getSerializer(tag) 2414 .receiveFromStream(socketInput); 2415 return result; 2416 } 2417 } 2418 catch (NotImplementedException nie) 2419 { 2420 throw new DriverSQLException("Internal bug: getSerializer failed" 2421 + " in getStaticMetadata", nie); 2422 } 2423 catch (IOException e) 2424 { 2425 throw wrapIOExceptionInDriverSQLException("getStaticMetadata", e); 2426 } 2427 } 2428 2429 private DriverSQLException wrapIOExceptionInDriverSQLException( 2430 String callerName, IOException ioe) 2431 { 2432 return new DriverSQLException("I/O Error on method " + callerName + "():\n" 2433 + ioe.getLocalizedMessage(), ioe); 2434 } 2435 2436 2442 public synchronized String getControllerVersionNumber() 2443 throws DriverSQLException 2444 { 2445 throwSQLExceptionIfClosed(); 2446 try 2447 { 2448 socketOutput.writeInt(Commands.GetControllerVersionNumber); 2449 socketOutput.flush(); 2450 2451 if (cjdbcUrl.isDebugEnabled()) 2452 System.out.println("Connection.getControllerVersionNumber()"); 2453 2454 return receiveString(); 2455 } 2456 catch (SerializableException e) 2457 { 2458 throw new DriverSQLException(e); 2459 } 2460 catch (IOException e) 2461 { 2462 throw wrapIOExceptionInDriverSQLException("getControllerVersionNumber", e); 2463 } 2464 } 2465 2466 2468 2482 public void setHoldability(int holdability) throws SQLException 2483 { 2484 throw new NotImplementedException("setHoldability"); 2485 } 2486 2487 2499 public int getHoldability() throws SQLException 2500 { 2501 throw new NotImplementedException("getHoldability"); 2502 } 2503 2504 2515 public Savepoint setSavepoint() throws DriverSQLException 2516 { 2517 throwSQLExceptionIfClosed(); 2518 if (autoCommit) 2519 throw new DriverSQLException( 2520 "Trying to set a savepoint in autocommit mode"); 2521 2522 if (driver == null) 2523 throw new DriverSQLException("No driver to set a savepoint"); 2524 2525 try 2526 { 2527 socketOutput.writeInt(Commands.SetUnnamedSavepoint); 2528 socketOutput.flush(); 2529 2530 int savepointId = receiveInt(); 2531 return new org.objectweb.cjdbc.driver.Savepoint(savepointId); 2532 } 2533 catch (SerializableException e) 2534 { 2535 throw new DriverSQLException(e); 2536 } 2537 catch (IOException ioe) 2538 { 2539 throw wrapIOExceptionInDriverSQLException("setSavePoint", ioe); 2540 } 2541 } 2542 2543 2555 public Savepoint setSavepoint(String name) throws DriverSQLException 2556 { 2557 throwSQLExceptionIfClosed(); 2558 if (name == null) 2559 throw new IllegalArgumentException ("Savepoint name cannot be null"); 2560 2561 if (autoCommit) 2562 throw new DriverSQLException( 2563 "Trying to set a savepoint in autocommit mode"); 2564 2565 if (driver == null) 2566 throw new DriverSQLException("No driver to set a savepoint"); 2567 2568 try 2569 { 2570 socketOutput.writeInt(Commands.SetNamedSavepoint); 2571 socketOutput.writeUTF(name); 2572 socketOutput.flush(); 2573 2574 this.receiveBoolean(); 2575 return new org.objectweb.cjdbc.driver.Savepoint(name); 2576 } 2577 catch (SerializableException se) 2578 { 2579 throw new DriverSQLException(se); 2580 } 2581 catch (IOException e) 2582 { 2583 throw wrapIOExceptionInDriverSQLException("setSavePoint", e); 2584 } 2585 } 2586 2587 2602 public void rollback(Savepoint savepoint) throws DriverSQLException 2603 { 2604 throwSQLExceptionIfClosed(); 2605 if (savepoint == null) 2606 throw new IllegalArgumentException ("Savepoint cannot be null"); 2607 2608 if (autoCommit) 2609 throw new DriverSQLException( 2610 "Trying to release a savepoint in autocommit mode"); 2611 2612 if (driver == null) 2613 throw new DriverSQLException("No driver to release a savepoint"); 2614 2615 try 2616 { 2617 socketOutput.writeInt(Commands.RollbackToSavepoint); 2618 savepointOnStream(savepoint); 2619 socketOutput.flush(); 2620 2621 this.receiveBoolean(); 2622 } 2623 catch (SerializableException e) 2624 { 2625 throw new DriverSQLException(e); 2626 } 2627 catch (IOException e) 2628 { 2629 throw wrapIOExceptionInDriverSQLException("(savepoint) rollback", e); 2630 } 2631 } 2632 2633 2644 public void releaseSavepoint(Savepoint savepoint) throws DriverSQLException 2645 { 2646 throwSQLExceptionIfClosed(); 2647 if (savepoint == null) 2648 throw new IllegalArgumentException ("Savepoint cannot be null"); 2649 2650 if (autoCommit) 2651 throw new DriverSQLException( 2652 "Trying to release a savepoint in autocommit mode"); 2653 2654 if (driver == null) 2655 throw new DriverSQLException("No driver to release a savepoint"); 2656 2657 try 2658 { 2659 socketOutput.writeInt(Commands.ReleaseSavepoint); 2660 savepointOnStream(savepoint); 2661 socketOutput.flush(); 2662 2663 this.receiveBoolean(); 2664 } 2665 catch (SerializableException e) 2666 { 2667 throw new DriverSQLException(e); 2668 } 2669 catch (IOException e) 2670 { 2671 throw wrapIOExceptionInDriverSQLException("releaseSavepoint", e); 2672 } 2673 } 2674 2675 2703 public java.sql.Statement createStatement(int resultSetType, 2704 int resultSetConcurrency, int resultSetHoldability) throws SQLException 2705 { 2706 throw new NotImplementedException("createStatement"); 2707 } 2708 2709 2740 public java.sql.PreparedStatement prepareStatement(String sql, 2741 int resultSetType, int resultSetConcurrency, int resultSetHoldability) 2742 throws SQLException 2743 { 2744 throw new NotImplementedException("prepareStatement"); 2745 } 2746 2747 2776 public java.sql.CallableStatement prepareCall(String sql, int resultSetType, 2777 int resultSetConcurrency, int resultSetHoldability) throws SQLException 2778 { 2779 throw new NotImplementedException("prepareCall"); 2780 } 2781 2782 2816 public java.sql.PreparedStatement prepareStatement(String sql, 2817 int autoGeneratedKeys) throws SQLException 2818 { 2819 throwSQLExceptionIfClosed(); 2820 PreparedStatement ps = new PreparedStatement(this, sql); 2821 ps.setGeneratedKeysFlag(autoGeneratedKeys); 2822 return ps; 2823 } 2824 2825 2859 public java.sql.PreparedStatement prepareStatement(String sql, 2860 int[] columnIndexes) throws SQLException 2861 { 2862 throw new NotImplementedException("prepareStatement"); 2863 } 2864 2865 2899 public java.sql.PreparedStatement prepareStatement(String sql, 2900 String [] columnNames) throws SQLException 2901 { 2902 throw new NotImplementedException("prepareStatement"); 2903 } 2904 2905 2913 public synchronized ResultSet getTableTypes() throws SQLException 2914 { 2915 throwSQLExceptionIfClosed(); 2916 String myName = "Connection.getTableTypes"; 2917 try 2918 { 2919 socketOutput.writeInt(Commands.DatabaseMetaDataGetTableTypes); 2920 socketOutput.flush(); 2921 2922 if (cjdbcUrl.isDebugEnabled()) 2923 System.out.println(myName); 2924 2925 return receiveResultSet(myName); 2926 } 2927 catch (SerializableException e) 2928 { 2929 throw new DriverSQLException(e); 2930 } 2931 catch (IOException e) 2932 { 2933 throw wrapIOExceptionInDriverSQLException("getTableTypes", e); 2934 } 2935 } 2936 2937 2953 public synchronized ResultSet getTablePrivileges(String catalog, 2954 String schemaPattern, String tableNamePattern) throws DriverSQLException 2955 { 2956 throwSQLExceptionIfClosed(); 2957 String myName = "Connection.getTablePrivileges"; 2958 try 2959 { 2960 socketOutput.writeInt(Commands.DatabaseMetaDataGetTablePrivileges); 2961 socketOutput.writeUTF(catalog); 2962 socketOutput.writeUTF(schemaPattern); 2963 socketOutput.writeUTF(tableNamePattern); 2964 socketOutput.flush(); 2965 2966 if (cjdbcUrl.isDebugEnabled()) 2967 System.out.println(myName + "(" + catalog + "," + schemaPattern + "," 2968 + tableNamePattern + ")"); 2969 2970 return receiveResultSet(myName); 2971 } 2972 catch (SerializableException e) 2973 { 2974 throw new DriverSQLException(e); 2975 } 2976 catch (IOException e) 2977 { 2978 throw wrapIOExceptionInDriverSQLException("getTablePrivileges", e); 2979 } 2980 } 2981 2982 2985 public synchronized ResultSet getSchemas() throws DriverSQLException 2986 { 2987 throwSQLExceptionIfClosed(); 2988 String myName = "Connection.getSchemas()"; 2989 2990 try 2991 { 2992 socketOutput.writeInt(Commands.DatabaseMetaDataGetSchemas); 2993 socketOutput.flush(); 2994 2995 if (cjdbcUrl.isDebugEnabled()) 2996 System.out.println(myName); 2997 2998 return receiveResultSet(myName); 2999 } 3000 catch (SerializableException e) 3001 { 3002 throw new DriverSQLException(e); 3003 } 3004 catch (IOException e) 3005 { 3006 throw wrapIOExceptionInDriverSQLException("getSchemas", e); 3007 } 3008 } 3009 3010 3013 public synchronized String getDatabaseProductName() throws DriverSQLException 3014 { 3015 throwSQLExceptionIfClosed(); 3016 try 3017 { 3018 socketOutput.writeInt(Commands.DatabaseMetaDataGetDatabaseProductName); 3019 socketOutput.flush(); 3020 3021 if (cjdbcUrl.isDebugEnabled()) 3022 System.out.println("Connection.getDatabaseProductName()"); 3023 3024 return receiveString(); 3025 } 3026 catch (SerializableException e) 3027 { 3028 throw new DriverSQLException(e); 3029 } 3030 catch (IOException e) 3031 { 3032 throw wrapIOExceptionInDriverSQLException("getDatabaseProductName", e); 3033 } 3034 } 3035 3036 3045 public synchronized void fetchNextData(String cursorName, int fetchSize, 3046 DriverResultSet drsToUpdate) throws DriverSQLException 3047 { 3048 throwSQLExceptionIfClosed(); 3049 try 3050 { 3051 socketOutput.writeInt(Commands.FetchNextResultSetRows); 3052 socketOutput.writeUTF(cursorName); 3053 socketOutput.writeInt(fetchSize); 3054 socketOutput.flush(); 3055 if (cjdbcUrl.isDebugEnabled()) 3056 System.out 3057 .println("Fetching next " + fetchSize + " from " + cursorName); 3058 3059 TypeTag tag = new TypeTag(socketInput); 3060 3061 if (TypeTag.EXCEPTION.equals(tag)) 3062 throw new DriverSQLException(receiveException()); 3063 3064 if (!TypeTag.NOT_EXCEPTION.equals(tag)) 3065 throw new ProtocolException(); 3066 3067 drsToUpdate.receiveRows(socketInput); 3068 3069 } 3070 catch (IOException e) 3071 { 3072 throw wrapIOExceptionInDriverSQLException("fetchNextData", e); 3073 } 3074 } 3075 3076 3082 public synchronized void closeRemoteResultSet(String cursorName) 3083 throws SQLException 3084 { 3085 throwSQLExceptionIfClosed(); 3086 try 3087 { 3088 socketOutput.writeInt(Commands.CloseRemoteResultSet); 3089 socketOutput.writeUTF(cursorName); 3090 socketOutput.flush(); 3091 if (cjdbcUrl.isDebugEnabled()) 3092 System.out.println("Closing remote ResultSet"); 3093 3094 receiveBoolean(); 3095 } 3096 catch (SerializableException se) 3097 { 3098 throw new DriverSQLException(se); 3099 } 3100 catch (IOException e) 3101 { 3102 throw wrapIOExceptionInDriverSQLException("closeRemoteResultSet", e); 3103 } 3104 } 3105 3106 3111 public String getPreparedStatementBooleanFalse() 3112 { 3113 return preparedStatementBooleanFalse; 3114 } 3115 3116 3121 public void setPreparedStatementBooleanFalse(String booleanFalse) 3122 { 3123 this.preparedStatementBooleanFalse = booleanFalse; 3124 } 3125 3126 3131 public String getPreparedStatementBooleanTrue() 3132 { 3133 return preparedStatementBooleanTrue; 3134 } 3135 3136 3141 public void setPreparedStatementBooleanTrue(String booleanTrue) 3142 { 3143 this.preparedStatementBooleanTrue = booleanTrue; 3144 } 3145 3146 3151 public boolean isEscapeBackslash() 3152 { 3153 return escapeBackslash; 3154 } 3155 3156 3161 public void setEscapeBackslash(boolean escapeBackslash) 3162 { 3163 this.escapeBackslash = escapeBackslash; 3164 } 3165 3166 3171 public boolean isEscapeSingleQuote() 3172 { 3173 return escapeSingleQuote; 3174 } 3175 3176 3181 public void setEscapeSingleQuote(boolean escapeSingleQuote) 3182 { 3183 this.escapeSingleQuote = escapeSingleQuote; 3184 } 3185 3186 3192 void setDriverProcessed(boolean processedByDriver) 3193 { 3194 this.driverProcessed = processedByDriver; 3195 } 3196 3197 3200 boolean isDriverProcessed() 3201 { 3202 return driverProcessed; 3203 } 3204 3205 3210 public void setEscapeChar(String escapeChar) 3211 { 3212 this.escapeChar = escapeChar; 3213 } 3214 3215 3218 public String getEscapeChar() 3219 { 3220 return escapeChar; 3221 } 3222 3223 3228 public boolean isConnectionPooling() 3229 { 3230 return connectionPooling; 3231 } 3232 3233 3238 public void setConnectionPooling(boolean connectionPooling) 3239 { 3240 this.connectionPooling = connectionPooling; 3241 } 3242 3243 3246 public String toString() 3247 { 3248 return "url:" + getUrl() + LINE_SEPARATOR + "user:" + getUserName() 3250 + LINE_SEPARATOR + "blobFilter:" + blobFilter + LINE_SEPARATOR 3251 + "connection pooling:" + connectionPooling + LINE_SEPARATOR 3252 + "driver processed:" + driverProcessed + LINE_SEPARATOR 3253 + "escape backslash:" + escapeBackslash + LINE_SEPARATOR 3254 + "escape char:" + escapeChar + LINE_SEPARATOR + "escape single quote:" 3255 + escapeSingleQuote + LINE_SEPARATOR + "preparedStatementBooleanTrue:" 3256 + preparedStatementBooleanTrue + LINE_SEPARATOR 3257 + "preparedStatementBooleanFalse" + preparedStatementBooleanFalse 3258 + LINE_SEPARATOR; 3259 } 3260 3261} 3262 | Popular Tags |