1 19 package com.mysql.jdbc; 20 21 import java.io.IOException ; 22 import java.io.InputStream ; 23 import java.io.Reader ; 24 import java.io.UnsupportedEncodingException ; 25 26 import java.math.BigDecimal ; 27 28 import java.net.URL ; 29 30 import java.sql.Clob ; 31 import java.sql.Date ; 32 import java.sql.ParameterMetaData ; 33 import java.sql.Ref ; 34 import java.sql.SQLException ; 35 import java.sql.Savepoint ; 36 import java.sql.Time ; 37 import java.sql.Timestamp ; 38 39 import java.util.ArrayList ; 40 import java.util.Calendar ; 41 import java.util.HashMap ; 42 import java.util.Iterator ; 43 import java.util.List ; 44 import java.util.Map ; 45 import java.util.Properties ; 46 import java.util.TimeZone ; 47 48 49 66 public class Connection implements java.sql.Connection { 67 private static final String PING_COMMAND = "SELECT 1"; 71 72 76 private static Map mapTransIsolationName2Value = null; 77 78 82 private static Map charsetMap; 83 84 85 private static Map multibyteCharsetsMap; 86 87 88 private static final String DEFAULT_SOCKET_FACTORY = StandardSocketFactory.class 89 .getName(); 90 91 static { 92 loadCharacterSetMapping(); 93 mapTransIsolationName2Value = new HashMap (8); 94 mapTransIsolationName2Value.put("READ-UNCOMMITED", 95 new Integer (TRANSACTION_READ_UNCOMMITTED)); 96 mapTransIsolationName2Value.put("READ-UNCOMMITTED", 97 new Integer (TRANSACTION_READ_UNCOMMITTED)); 98 mapTransIsolationName2Value.put("READ-COMMITTED", 99 new Integer (TRANSACTION_READ_COMMITTED)); 100 mapTransIsolationName2Value.put("REPEATABLE-READ", 101 new Integer (TRANSACTION_REPEATABLE_READ)); 102 mapTransIsolationName2Value.put("SERIALIZABLE", 103 new Integer (TRANSACTION_SERIALIZABLE)); 104 } 105 106 110 private final static Object CHARSET_CONVERTER_NOT_AVAILABLE_MARKER = new Object (); 111 112 113 private DatabaseMetaData dbmd = null; 114 115 116 private List hostList = null; 117 118 119 private Map cachedPreparedStatementParams; 120 121 126 private Map charsetConverterMap = new HashMap (CharsetMapping.JAVA_TO_MYSQL_CHARSET_MAP 127 .size()); 128 129 130 private Map statementsUsingMaxRows; 131 132 136 private Map typeMap; 137 138 139 private MysqlIO io = null; 140 141 142 private final Object mutex = new Object (); 143 144 145 private Map serverVariables = null; 146 147 148 private NonRegisteringDriver myDriver; 149 150 151 private Properties props = null; 152 153 154 private String database = null; 155 156 157 private String encoding = null; 158 159 160 private String host = null; 161 162 163 private String myURL = null; 164 165 166 private String mysqlEncodingName = null; 167 private String negativeInfinityRep = MysqlDefs.MIN_DOUBLE_VAL_STRING; 168 private String notANumberRep = MysqlDefs.NAN_VAL_STRING; 169 170 171 private String password = null; 172 private String positiveInfinityRep = MysqlDefs.MAX_DOUBLE_VAL_STRING; 173 174 175 private String socketFactoryClassName = null; 176 177 178 private String user = null; 179 180 181 private Throwable explicitCloseLocation; 182 183 184 private Throwable forcedCloseReason; 185 private TimeZone defaultTimeZone; 186 187 188 private TimeZone serverTimezone = null; 189 190 191 private boolean allowLoadLocalInfile = true; 192 193 194 private boolean alwaysClearStream = false; 195 196 197 private boolean autoCommit = true; 198 199 200 private boolean cachePreparedStatements = false; 201 202 203 private boolean capitalizeDBMDTypes = false; 204 205 206 private boolean clobberStreamingResults = false; 207 208 212 private boolean continueBatchOnError = true; 213 214 215 private boolean doUnicode = false; 216 217 218 private boolean failedOver = false; 219 220 221 private boolean hasIsolationLevels = false; 222 223 224 private boolean hasQuotedIdentifiers = false; 225 226 private boolean highAvailability = false; 230 231 232 private boolean ignoreNonTxTables = false; 233 234 235 private boolean isClosed = true; 236 237 238 private boolean isInteractiveClient = false; 239 240 241 private boolean lowerCaseTableNames = false; 242 243 244 private boolean maxRowsChanged = false; 245 private boolean negativeInfinityRepIsClipped = true; 246 private boolean notANumberRepIsClipped = true; 247 248 249 private boolean paranoid = false; 250 251 252 private boolean pedantic = false; 253 private boolean positiveInfinityRepIsClipped = true; 254 255 256 private boolean readInfoMsg = false; 257 258 259 private boolean readOnly = false; 260 261 265 private boolean reconnectAtTxEnd = false; 266 267 268 private boolean relaxAutoCommit = false; 269 270 271 private boolean strictFloatingPoint = false; 272 273 274 private boolean strictUpdates = true; 275 276 277 private boolean transactionsSupported = false; 278 279 280 private boolean useAnsiQuotes = false; 281 282 283 private boolean useCompression = false; 284 285 286 private boolean useFastPing = false; 287 288 289 private boolean useHostsInPrivileges = true; 290 291 292 private boolean useSSL = false; 293 294 298 private boolean useStreamLengthsInPrepStmts = true; 299 300 301 private boolean useTimezone = false; 302 303 304 private boolean useUltraDevWorkAround = false; 305 private boolean useUnbufferedInput = true; 306 private double initialTimeout = 2.0D; 307 308 309 private int hostListSize = 0; 310 311 312 private int isolationLevel = java.sql.Connection.TRANSACTION_READ_COMMITTED; 313 314 318 private int maxAllowedPacket = 65536; 319 private int maxReconnects = 3; 320 321 325 private int maxRows = -1; 326 private int netBufferLength = 16384; 327 328 329 private int port = 3306; 330 331 335 private int preparedStatementCacheMaxSqlSize = 256; 336 337 338 private int preparedStatementCacheSize = 25; 339 340 344 private int queriesBeforeRetryMaster = 50; 345 346 347 private int socketTimeout = 0; 349 350 private long lastQueryFinishedTime = 0; 351 352 353 private long masterFailTimeMillis = 0L; 354 355 356 private long queriesIssuedFailedOver = 0; 357 358 363 private long secondsBeforeRetryMaster = 30L; 364 365 378 Connection(String host, int port, Properties info, String database, 379 String url, NonRegisteringDriver d) throws java.sql.SQLException { 380 if (Driver.TRACE) { 381 Object [] args = { host, new Integer (port), info, database, url, d }; 382 Debug.methodCall(this, "constructor", args); 383 } 384 385 this.defaultTimeZone = TimeZone.getDefault(); 386 387 this.serverVariables = new HashMap (); 388 389 if (host == null) { 390 this.host = "localhost"; 391 hostList = new ArrayList (); 392 hostList.add(this.host); 393 } else if (host.indexOf(",") != -1) { 394 hostList = StringUtils.split(host, ",", true); 396 } else { 397 this.host = host; 398 hostList = new ArrayList (); 399 hostList.add(this.host); 400 } 401 402 hostListSize = hostList.size(); 403 this.port = port; 404 405 if (database == null) { 406 throw new SQLException ("Malformed URL '" + url + "'.", 407 SQLError.SQL_STATE_GENERAL_ERROR); 408 } 409 410 this.database = database; 411 this.myURL = url; 412 this.myDriver = d; 413 this.user = info.getProperty("user"); 414 this.password = info.getProperty("password"); 415 416 if ((this.user == null) || this.user.equals("")) { 417 this.user = "nobody"; 418 } 419 420 if (this.password == null) { 421 this.password = ""; 422 } 423 424 this.props = info; 425 initializeDriverProperties(info); 426 427 if (Driver.DEBUG) { 428 System.out.println("Connect: " + this.user + " to " + this.database); 429 } 430 431 try { 432 createNewIO(false); 433 this.dbmd = new DatabaseMetaData(this, this.database); 434 } catch (java.sql.SQLException ex) { 435 cleanup(ex); 436 437 throw ex; 439 } catch (Exception ex) { 440 cleanup(ex); 441 442 StringBuffer mesg = new StringBuffer (); 443 444 if (!useParanoidErrorMessages()) { 445 mesg.append("Cannot connect to MySQL server on "); 446 mesg.append(this.host); 447 mesg.append(":"); 448 mesg.append(this.port); 449 mesg.append(".\n\n"); 450 mesg.append("Make sure that there is a MySQL server "); 451 mesg.append("running on the machine/port you are trying "); 452 mesg.append( 453 "to connect to and that the machine this software is " 454 + "running on "); 455 mesg.append("is able to connect to this host/port " 456 + "(i.e. not firewalled). "); 457 mesg.append( 458 "Also make sure that the server has not been started " 459 + "with the --skip-networking "); 460 mesg.append("flag.\n\n"); 461 } else { 462 mesg.append("Unable to connect to database."); 463 } 464 465 mesg.append("Underlying exception: \n\n"); 466 mesg.append(ex.getClass().getName()); 467 throw new java.sql.SQLException (mesg.toString(), 468 SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE); 469 } 470 } 471 472 495 public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException { 496 if (Driver.TRACE) { 497 Object [] args = { new Boolean (autoCommit) }; 498 Debug.methodCall(this, "setAutoCommit", args); 499 } 500 501 checkClosed(); 502 503 if (this.transactionsSupported) { 504 this.autoCommit = autoCommit; 512 513 if ((this.highAvailability || this.failedOver) && !this.autoCommit) { 518 pingAndReconnect(true); 519 } 520 521 String sql = "SET autocommit=" + (autoCommit ? "1" : "0"); 522 execSQL(sql, -1, this.database); 523 } else { 524 if ((autoCommit == false) && (this.relaxAutoCommit == false)) { 525 throw new SQLException ("MySQL Versions Older than 3.23.15 " 526 + "do not support transactions", 527 SQLError.SQL_STATE_DRIVER_NOT_CAPABLE); 528 } else { 529 this.autoCommit = autoCommit; 530 } 531 } 532 533 return; 534 } 535 536 545 public boolean getAutoCommit() throws java.sql.SQLException { 546 if (Driver.TRACE) { 547 Object [] args = new Object [0]; 548 Debug.methodCall(this, "getAutoCommit", args); 549 Debug.returnValue(this, "getAutoCommit", 550 new Boolean (this.autoCommit)); 551 } 552 553 return this.autoCommit; 554 } 555 556 569 public void setCatalog(String catalog) throws java.sql.SQLException { 570 if (Driver.TRACE) { 571 Object [] args = { catalog }; 572 Debug.methodCall(this, "setCatalog", args); 573 } 574 575 checkClosed(); 576 577 String quotedId = this.dbmd.getIdentifierQuoteString(); 578 579 if ((quotedId == null) || quotedId.equals(" ")) { 580 quotedId = ""; 581 } 582 583 StringBuffer query = new StringBuffer ("USE "); 584 query.append(quotedId); 585 query.append(catalog); 586 query.append(quotedId); 587 588 execSQL(query.toString(), -1, catalog); 589 this.database = catalog; 590 } 591 592 604 public String getCatalog() throws java.sql.SQLException { 605 if (Driver.TRACE) { 606 Object [] args = new Object [0]; 607 Debug.methodCall(this, "getCatalog", args); 608 Debug.returnValue(this, "getCatalog", this.database); 609 } 610 611 return this.database; 612 } 613 614 621 public boolean getClobberStreamingResults() { 622 return this.clobberStreamingResults; 623 } 624 625 630 public boolean isClosed() { 631 if (Driver.TRACE) { 632 Object [] args = new Object [0]; 633 Debug.methodCall(this, "isClosed", args); 634 Debug.returnValue(this, "isClosed", new Boolean (this.isClosed)); 635 } 636 637 return this.isClosed; 638 } 639 640 645 public String getEncoding() { 646 return this.encoding; 647 } 648 649 652 public void setHoldability(int arg0) throws SQLException { 653 } 655 656 659 public int getHoldability() throws SQLException { 660 return ResultSet.CLOSE_CURSORS_AT_COMMIT; 661 } 662 663 671 public long getIdleFor() { 672 if (this.lastQueryFinishedTime == 0) { 673 return 0; 674 } else { 675 long now = System.currentTimeMillis(); 676 long idleTime = now - this.lastQueryFinishedTime; 677 678 return idleTime; 679 } 680 } 681 682 687 public boolean isInteractiveClient() { 688 return isInteractiveClient; 689 } 690 691 701 public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException { 702 checkClosed(); 703 704 return new DatabaseMetaData(this, this.database); 705 } 706 707 712 public String getNegativeInfinityRep() { 713 return negativeInfinityRep; 714 } 715 716 721 public boolean isNegativeInfinityRepIsClipped() { 722 return negativeInfinityRepIsClipped; 723 } 724 725 730 public String getNotANumberRep() { 731 return notANumberRep; 732 } 733 734 739 public boolean isNotANumberRepIsClipped() { 740 return notANumberRepIsClipped; 741 } 742 743 748 public String getPositiveInfinityRep() { 749 return positiveInfinityRep; 750 } 751 752 757 public boolean isPositiveInfinityRepIsClipped() { 758 return positiveInfinityRepIsClipped; 759 } 760 761 768 public void setProfileSql(boolean flag) throws SQLException { 769 this.props.setProperty("profileSql", String.valueOf(flag)); 771 getIO().setProfileSql(flag); 772 } 773 774 783 public void setReadOnly(boolean readOnly) throws java.sql.SQLException { 784 if (Driver.TRACE) { 785 Object [] args = { new Boolean (readOnly) }; 786 Debug.methodCall(this, "setReadOnly", args); 787 Debug.returnValue(this, "setReadOnly", new Boolean (readOnly)); 788 } 789 790 checkClosed(); 791 this.readOnly = readOnly; 792 } 793 794 803 public boolean isReadOnly() throws java.sql.SQLException { 804 if (Driver.TRACE) { 805 Object [] args = new Object [0]; 806 Debug.methodCall(this, "isReadOnly", args); 807 Debug.returnValue(this, "isReadOnly", new Boolean (this.readOnly)); 808 } 809 810 return this.readOnly; 811 } 812 813 816 public java.sql.Savepoint setSavepoint() throws SQLException { 817 throw new NotImplemented(); 818 } 819 820 823 public java.sql.Savepoint setSavepoint(String arg0) 824 throws SQLException { 825 throw new NotImplemented(); 826 } 827 828 833 public TimeZone getServerTimezone() { 834 return this.serverTimezone; 835 } 836 837 845 public void setTransactionIsolation(int level) throws java.sql.SQLException { 846 if (Driver.TRACE) { 847 Object [] args = { new Integer (level) }; 848 Debug.methodCall(this, "setTransactionIsolation", args); 849 } 850 851 checkClosed(); 852 853 if (this.hasIsolationLevels) { 854 StringBuffer sql = new StringBuffer ( 855 "SET SESSION TRANSACTION ISOLATION LEVEL "); 856 857 switch (level) { 858 case java.sql.Connection.TRANSACTION_NONE: 859 throw new SQLException ("Transaction isolation level " 860 + "NONE not supported by MySQL"); 861 862 case java.sql.Connection.TRANSACTION_READ_COMMITTED: 863 sql.append("READ COMMITTED"); 864 865 break; 866 867 case java.sql.Connection.TRANSACTION_READ_UNCOMMITTED: 868 sql.append("READ UNCOMMITTED"); 869 870 break; 871 872 case java.sql.Connection.TRANSACTION_REPEATABLE_READ: 873 sql.append("REPEATABLE READ"); 874 875 break; 876 877 case java.sql.Connection.TRANSACTION_SERIALIZABLE: 878 sql.append("SERIALIZABLE"); 879 880 break; 881 882 default: 883 throw new SQLException ("Unsupported transaction " 884 + "isolation level '" + level + "'", "S1C00"); 885 } 886 887 execSQL(sql.toString(), -1, this.database); 888 isolationLevel = level; 889 } else { 890 throw new java.sql.SQLException ("Transaction Isolation Levels are " 891 + "not supported on MySQL versions older than 3.23.36.", "S1C00"); 892 } 893 } 894 895 903 public int getTransactionIsolation() throws java.sql.SQLException { 904 if (Driver.TRACE) { 905 Object [] args = new Object [0]; 906 Debug.methodCall(this, "getTransactionIsolation", args); 907 Debug.returnValue(this, "getTransactionIsolation", 908 new Integer (isolationLevel)); 909 } 910 911 if (this.hasIsolationLevels) { 912 java.sql.Statement stmt = null; 913 java.sql.ResultSet rs = null; 914 915 try { 916 stmt = this.createStatement(); 917 918 if (stmt.getMaxRows() != 0) { 919 stmt.setMaxRows(0); 920 } 921 922 String query = null; 923 924 if (this.io.versionMeetsMinimum(4, 0, 3)) { 925 query = "SHOW VARIABLES LIKE 'tx_isolation'"; 926 } else { 927 query = "SHOW VARIABLES LIKE 'transaction_isolation'"; 928 } 929 930 rs = stmt.executeQuery(query); 931 932 if (rs.next()) { 933 String s = rs.getString(2); 934 935 if (s != null) { 936 Integer intTI = (Integer ) mapTransIsolationName2Value 937 .get(s); 938 939 if (intTI != null) { 940 return intTI.intValue(); 941 } 942 } 943 944 throw new SQLException ( 945 "Could not map transaction isolation '" + s 946 + " to a valid JDBC level.", 947 SQLError.SQL_STATE_GENERAL_ERROR); 948 } else { 949 throw new SQLException ("Could not retrieve transaction isolation level from server", 950 SQLError.SQL_STATE_GENERAL_ERROR); 951 } 952 } finally { 953 if (rs != null) { 954 try { 955 rs.close(); 956 } catch (Exception ex) { 957 } 959 960 rs = null; 961 } 962 963 if (stmt != null) { 964 try { 965 stmt.close(); 966 } catch (Exception ex) { 967 } 969 970 stmt = null; 971 } 972 } 973 } 974 975 return isolationLevel; 976 } 977 978 986 public void setTypeMap(java.util.Map map) throws SQLException { 987 this.typeMap = map; 988 } 989 990 998 public synchronized java.util.Map getTypeMap() throws SQLException { 999 if (this.typeMap == null) { 1000 this.typeMap = new HashMap (); 1001 } 1002 1003 return this.typeMap; 1004 } 1005 1006 1015 public java.sql.SQLWarning getWarnings() throws java.sql.SQLException { 1016 if (Driver.TRACE) { 1017 Object [] args = new Object [0]; 1018 Debug.methodCall(this, "getWarnings", args); 1019 Debug.returnValue(this, "getWarnings", null); 1020 } 1021 1022 return null; 1023 } 1024 1025 1030 public boolean allowLoadLocalInfile() { 1031 return this.allowLoadLocalInfile; 1032 } 1033 1034 1039 public boolean capitalizeDBMDTypes() { 1040 return this.capitalizeDBMDTypes; 1041 } 1042 1043 1049 public void clearWarnings() throws java.sql.SQLException { 1050 if (Driver.TRACE) { 1051 Object [] args = new Object [0]; 1052 Debug.methodCall(this, "clearWarnings", args); 1053 } 1054 1055 } 1057 1058 1067 public void close() throws java.sql.SQLException { 1068 if (this.explicitCloseLocation == null) { 1069 this.explicitCloseLocation = new Throwable (); 1070 } 1071 1072 realClose(true, true); 1073 } 1074 1075 1091 public void commit() throws java.sql.SQLException { 1092 if (Driver.TRACE) { 1093 Object [] args = new Object [0]; 1094 Debug.methodCall(this, "commit", args); 1095 } 1096 1097 checkClosed(); 1098 1099 try { 1100 if (this.autoCommit && !this.relaxAutoCommit) { 1102 throw new SQLException ("Can't call commit when autocommit=true", 1103 SQLError.SQL_STATE_GENERAL_ERROR); 1104 } else if (this.transactionsSupported) { 1105 execSQL("commit", -1, this.database); 1106 } 1107 } finally { 1108 if (this.reconnectAtTxEnd) { 1109 pingAndReconnect(true); 1110 } 1111 } 1112 1113 return; 1114 } 1115 1116 1118 1129 public java.sql.Statement createStatement(int resultSetType, 1130 int resultSetConcurrency) throws SQLException { 1131 checkClosed(); 1132 1133 Statement stmt = new com.mysql.jdbc.Statement(this, this.database); 1134 stmt.setResultSetType(resultSetType); 1135 stmt.setResultSetConcurrency(resultSetConcurrency); 1136 1137 return stmt; 1138 } 1139 1140 1149 public java.sql.Statement createStatement() throws SQLException { 1150 return createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, 1151 java.sql.ResultSet.CONCUR_READ_ONLY); 1152 } 1153 1154 1157 public java.sql.Statement createStatement(int resultSetType, 1158 int resultSetConcurrency, int resultSetHoldability) 1159 throws SQLException { 1160 if (this.pedantic) { 1161 if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) { 1162 throw new SQLException ("HOLD_CUSRORS_OVER_COMMIT is only supported holdability level", 1163 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 1164 } 1165 } 1166 1167 return createStatement(resultSetType, resultSetConcurrency); 1168 } 1169 1170 1175 public void finalize() throws Throwable { 1176 cleanup(null); 1177 } 1178 1179 1184 public boolean lowerCaseTableNames() { 1185 return this.lowerCaseTableNames; 1186 } 1187 1188 1200 public String nativeSQL(String sql) throws java.sql.SQLException { 1201 if (Driver.TRACE) { 1202 Object [] args = { sql }; 1203 Debug.methodCall(this, "nativeSQL", args); 1204 Debug.returnValue(this, "nativeSQL", sql); 1205 } 1206 1207 return EscapeProcessor.escapeSQL(sql, 1208 getIO().versionMeetsMinimum(4, 0, 2)); 1209 } 1210 1211 1220 public java.sql.CallableStatement prepareCall(String sql) 1221 throws java.sql.SQLException { 1222 if (this.getUseUltraDevWorkAround()) { 1223 return new UltraDevWorkAround(prepareStatement(sql)); 1224 } else { 1225 throw new java.sql.SQLException ("Callable statments not " 1226 + "supported.", "S1C00"); 1227 } 1228 } 1229 1230 1243 public java.sql.CallableStatement prepareCall(String sql, 1244 int resultSetType, int resultSetConcurrency) throws SQLException { 1245 return prepareCall(sql); 1246 } 1247 1248 1251 public java.sql.CallableStatement prepareCall(String sql, 1252 int resultSetType, int resultSetConcurrency, int resultSetHoldability) 1253 throws SQLException { 1254 if (this.pedantic) { 1255 if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) { 1256 throw new SQLException ("HOLD_CUSRORS_OVER_COMMIT is only supported holdability level", 1257 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 1258 } 1259 } 1260 1261 throw new NotImplemented(); 1262 } 1263 1264 1291 public java.sql.PreparedStatement prepareStatement(String sql) 1292 throws java.sql.SQLException { 1293 return prepareStatement(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, 1294 java.sql.ResultSet.CONCUR_READ_ONLY); 1295 } 1296 1297 1310 public synchronized java.sql.PreparedStatement prepareStatement( 1311 String sql, int resultSetType, int resultSetConcurrency) 1312 throws SQLException { 1313 checkClosed(); 1314 1315 PreparedStatement pStmt = null; 1316 1317 if (this.cachePreparedStatements) { 1318 PreparedStatement.ParseInfo pStmtInfo = (PreparedStatement.ParseInfo) cachedPreparedStatementParams 1319 .get(sql); 1320 1321 if (pStmtInfo == null) { 1322 pStmt = new com.mysql.jdbc.PreparedStatement(this, sql, 1323 this.database); 1324 1325 PreparedStatement.ParseInfo parseInfo = pStmt.getParseInfo(); 1326 1327 if (parseInfo.statementLength < this.preparedStatementCacheMaxSqlSize) { 1328 if (this.cachedPreparedStatementParams.size() >= 25) { 1329 Iterator oldestIter = this.cachedPreparedStatementParams.keySet() 1330 .iterator(); 1331 long lruTime = Long.MAX_VALUE; 1332 String oldestSql = null; 1333 1334 while (oldestIter.hasNext()) { 1335 String sqlKey = (String ) oldestIter.next(); 1336 PreparedStatement.ParseInfo lruInfo = (PreparedStatement.ParseInfo) this.cachedPreparedStatementParams 1337 .get(sqlKey); 1338 1339 if (lruInfo.lastUsed < lruTime) { 1340 lruTime = lruInfo.lastUsed; 1341 oldestSql = sqlKey; 1342 } 1343 } 1344 1345 if (oldestSql != null) { 1346 this.cachedPreparedStatementParams.remove(oldestSql); 1347 } 1348 } 1349 1350 cachedPreparedStatementParams.put(sql, pStmt.getParseInfo()); 1351 } 1352 } else { 1353 pStmtInfo.lastUsed = System.currentTimeMillis(); 1354 pStmt = new com.mysql.jdbc.PreparedStatement(this, sql, 1355 this.database, pStmtInfo); 1356 } 1357 } else { 1358 pStmt = new com.mysql.jdbc.PreparedStatement(this, sql, 1359 this.database); 1360 } 1361 1362 pStmt.setResultSetType(resultSetType); 1367 pStmt.setResultSetConcurrency(resultSetConcurrency); 1368 1369 return pStmt; 1370 } 1371 1372 1375 public java.sql.PreparedStatement prepareStatement(String sql, 1376 int resultSetType, int resultSetConcurrency, int resultSetHoldability) 1377 throws SQLException { 1378 if (this.pedantic) { 1379 if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) { 1380 throw new SQLException ("HOLD_CUSRORS_OVER_COMMIT is only supported holdability level", 1381 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 1382 } 1383 } 1384 1385 return prepareStatement(sql, resultSetType, resultSetConcurrency); 1386 } 1387 1388 1391 public java.sql.PreparedStatement prepareStatement(String sql, 1392 int autoGenKeyIndex) throws SQLException { 1393 java.sql.PreparedStatement pStmt = prepareStatement(sql); 1394 1395 ((com.mysql.jdbc.PreparedStatement) pStmt).setRetrieveGeneratedKeys(autoGenKeyIndex == Statement.RETURN_GENERATED_KEYS); 1396 1397 return pStmt; 1398 } 1399 1400 1403 public java.sql.PreparedStatement prepareStatement(String sql, 1404 int[] autoGenKeyIndexes) throws SQLException { 1405 java.sql.PreparedStatement pStmt = prepareStatement(sql); 1406 1407 ((com.mysql.jdbc.PreparedStatement) pStmt).setRetrieveGeneratedKeys((autoGenKeyIndexes != null) 1408 && (autoGenKeyIndexes.length > 0)); 1409 1410 return pStmt; 1411 } 1412 1413 1416 public java.sql.PreparedStatement prepareStatement(String sql, 1417 String [] autoGenKeyColNames) throws SQLException { 1418 java.sql.PreparedStatement pStmt = prepareStatement(sql); 1419 1420 ((com.mysql.jdbc.PreparedStatement) pStmt).setRetrieveGeneratedKeys((autoGenKeyColNames != null) 1421 && (autoGenKeyColNames.length > 0)); 1422 1423 return pStmt; 1424 } 1425 1426 1429 public void releaseSavepoint(Savepoint arg0) throws SQLException { 1430 throw new NotImplemented(); 1431 } 1432 1433 1443 public void rollback() throws java.sql.SQLException { 1444 if (Driver.TRACE) { 1445 Object [] args = new Object [0]; 1446 Debug.methodCall(this, "rollback", args); 1447 } 1448 1449 checkClosed(); 1450 1451 try { 1452 if (this.autoCommit && !this.relaxAutoCommit) { 1454 throw new SQLException ("Can't call rollback when autocommit=true", 1455 SQLError.SQL_STATE_GENERAL_ERROR); 1456 } else if (this.transactionsSupported) { 1457 try { 1458 rollbackNoChecks(); 1459 } catch (SQLException sqlEx) { 1460 if (this.ignoreNonTxTables 1462 && (sqlEx.getErrorCode() != MysqlDefs.ER_WARNING_NOT_COMPLETE_ROLLBACK)) { 1463 throw sqlEx; 1464 } 1465 } 1466 } 1467 } finally { 1468 if (this.reconnectAtTxEnd) { 1469 pingAndReconnect(true); 1470 } 1471 } 1472 } 1473 1474 1477 public void rollback(Savepoint arg0) throws SQLException { 1478 throw new NotImplemented(); 1479 } 1480 1481 1486 public void shutdownServer() throws SQLException { 1487 try { 1488 this.io.sendCommand(MysqlDefs.SHUTDOWN, null, null); 1489 } catch (Exception ex) { 1490 throw new SQLException ("Unhandled exception '" + ex.toString() 1491 + "'", SQLError.SQL_STATE_GENERAL_ERROR); 1492 } 1493 } 1494 1495 1500 public boolean supportsIsolationLevel() { 1501 return this.hasIsolationLevels; 1502 } 1503 1504 1509 public boolean supportsQuotedIdentifiers() { 1510 return this.hasQuotedIdentifiers; 1511 } 1512 1513 1518 public boolean supportsTransactions() { 1519 return this.transactionsSupported; 1520 } 1521 1522 1527 public boolean useCompression() { 1528 return this.useCompression; 1529 } 1530 1531 1536 public boolean useParanoidErrorMessages() { 1537 return paranoid; 1538 } 1539 1540 1545 public boolean useSSL() { 1546 return this.useSSL; 1547 } 1548 1549 1555 public boolean useStrictFloatingPoint() { 1556 return this.strictFloatingPoint; 1557 } 1558 1559 1564 public boolean useStrictUpdates() { 1565 return strictUpdates; 1566 } 1567 1568 1573 public boolean useTimezone() { 1574 return this.useTimezone; 1575 } 1576 1577 1582 public boolean useUnicode() { 1583 return this.doUnicode; 1584 } 1585 1586 1591 protected TimeZone getDefaultTimeZone() { 1592 return defaultTimeZone; 1593 } 1594 1595 1602 protected MysqlIO getIO() throws SQLException { 1603 if ((this.io == null) || this.isClosed) { 1604 throw new SQLException ("Operation not allowed on closed connection", 1605 "08003"); 1606 } 1607 1608 return this.io; 1609 } 1610 1611 protected int getNetWriteTimeout() { 1612 String netWriteTimeoutStr = (String ) this.serverVariables.get( 1613 "net_write_timeout"); 1614 1615 if (netWriteTimeoutStr != null) { 1616 try { 1617 return Integer.parseInt(netWriteTimeoutStr); 1618 } catch (NumberFormatException nfe) { 1619 return Integer.MAX_VALUE; 1620 } 1621 } else { 1622 return Integer.MAX_VALUE; 1623 } 1624 } 1625 1626 1631 protected boolean isUsingUnbufferedInput() { 1632 return this.useUnbufferedInput; 1633 } 1634 1635 1644 protected com.mysql.jdbc.MysqlIO createNewIO(boolean isForReconnect) 1645 throws SQLException { 1646 MysqlIO newIo = null; 1647 1648 if (!highAvailability && !this.failedOver) { 1649 for (int hostIndex = 0; hostIndex < hostListSize; hostIndex++) { 1650 try { 1651 this.io = new MysqlIO(this.hostList.get(hostIndex).toString(), 1652 this.port, this.socketFactoryClassName, this.props, 1653 this, this.socketTimeout); 1654 this.io.doHandshake(this.user, this.password, this.database); 1655 this.isClosed = false; 1656 1657 if (this.database.length() != 0) { 1658 this.io.sendCommand(MysqlDefs.INIT_DB, this.database, 1659 null); 1660 } 1661 1662 boolean autoCommit = getAutoCommit(); 1664 int oldIsolationLevel = getTransactionIsolation(); 1665 boolean oldReadOnly = isReadOnly(); 1666 String oldCatalog = getCatalog(); 1667 1668 initializePropsFromServer(this.props); 1672 1673 if (isForReconnect) { 1674 setAutoCommit(autoCommit); 1676 1677 if (this.hasIsolationLevels) { 1678 setTransactionIsolation(oldIsolationLevel); 1679 } 1680 1681 setCatalog(oldCatalog); 1682 } 1683 1684 if (hostIndex != 0) { 1685 setFailedOverState(); 1686 } else { 1687 this.failedOver = false; 1688 1689 if (hostListSize > 1) { 1690 setReadOnly(false); 1691 } else { 1692 setReadOnly(oldReadOnly); 1693 } 1694 } 1695 1696 break; } catch (SQLException sqlEx) { 1698 if (this.io != null) { 1699 this.io.forceClose(); 1700 } 1701 1702 String sqlState = sqlEx.getSQLState(); 1703 1704 if ((sqlState == null) 1705 || !sqlState.equals( 1706 SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE)) { 1707 throw sqlEx; 1708 } 1709 1710 if ((hostListSize - 1) == hostIndex) { 1711 throw sqlEx; 1712 } 1713 } catch (Exception unknownException) { 1714 if (this.io != null) { 1715 this.io.forceClose(); 1716 } 1717 1718 if ((hostListSize - 1) == hostIndex) { 1719 throw new SQLException ( 1720 "Unable to connect to any hosts due to exception: " 1721 + unknownException.toString(), 1722 SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE); 1723 } 1724 } 1725 } 1726 } else { 1727 double timeout = this.initialTimeout; 1728 boolean connectionGood = false; 1729 Exception connectionException = null; 1730 1731 for (int hostIndex = 0; 1732 (hostIndex < hostListSize) && !connectionGood; 1733 hostIndex++) { 1734 for (int attemptCount = 0; 1735 !connectionGood && (attemptCount < this.maxReconnects); 1736 attemptCount++) { 1737 try { 1738 if (this.io != null) { 1739 this.io.forceClose(); 1740 } 1741 1742 this.io = new MysqlIO(this.hostList.get(hostIndex) 1743 .toString(), 1744 this.port, this.socketFactoryClassName, 1745 this.props, this, this.socketTimeout); 1746 this.io.doHandshake(this.user, this.password, 1747 this.database); 1748 1749 if (this.database.length() != 0) { 1750 this.io.sendCommand(MysqlDefs.INIT_DB, 1751 this.database, null); 1752 } 1753 1754 ping(); 1755 this.isClosed = false; 1756 1757 boolean autoCommit = getAutoCommit(); 1759 int oldIsolationLevel = getTransactionIsolation(); 1760 boolean oldReadOnly = isReadOnly(); 1761 String oldCatalog = getCatalog(); 1762 1763 initializePropsFromServer(this.props); 1767 1768 if (isForReconnect) { 1769 setAutoCommit(autoCommit); 1771 1772 if (this.hasIsolationLevels) { 1773 setTransactionIsolation(oldIsolationLevel); 1774 } 1775 1776 setCatalog(oldCatalog); 1777 } 1778 1779 connectionGood = true; 1780 1781 if (hostIndex != 0) { 1782 setFailedOverState(); 1783 } else { 1784 this.failedOver = false; 1785 1786 if (hostListSize > 1) { 1787 setReadOnly(false); 1788 } else { 1789 setReadOnly(oldReadOnly); 1790 } 1791 } 1792 1793 break; 1794 } catch (Exception EEE) { 1795 connectionException = EEE; 1796 connectionGood = false; 1797 } 1798 1799 if (!connectionGood) { 1800 try { 1801 Thread.sleep((long) timeout * 1000); 1802 timeout = timeout * 2; 1803 } catch (InterruptedException IE) { 1804 ; 1805 } 1806 } 1807 } 1808 1809 if (!connectionGood) { 1810 throw new SQLException ( 1812 "Server connection failure during transaction. Due to underlying exception: '" 1813 + connectionException + "'.\nAttempted reconnect " 1814 + this.maxReconnects + " times. Giving up.", 1815 SQLError.SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE); 1816 } 1817 } 1818 } 1819 1820 if (paranoid && !highAvailability && (hostListSize <= 1)) { 1821 password = null; 1822 user = null; 1823 } 1824 1825 return newIo; 1826 } 1827 1828 1836 protected void realClose(boolean calledExplicitly, boolean issueRollback) 1837 throws SQLException { 1838 if (Driver.TRACE) { 1839 Object [] args = new Object [] { 1840 new Boolean (calledExplicitly), new Boolean (issueRollback) 1841 }; 1842 Debug.methodCall(this, "realClose", args); 1843 } 1844 1845 SQLException sqlEx = null; 1846 1847 if (!isClosed() && !getAutoCommit() && issueRollback) { 1848 try { 1849 rollback(); 1850 } catch (SQLException ex) { 1851 sqlEx = ex; 1852 } 1853 } 1854 1855 if (this.io != null) { 1856 try { 1857 this.io.quit(); 1858 } catch (Exception e) { 1859 ; 1860 } 1861 1862 this.io = null; 1863 } 1864 1865 if (this.cachedPreparedStatementParams != null) { 1866 this.cachedPreparedStatementParams.clear(); 1867 this.cachedPreparedStatementParams = null; 1868 } 1869 1870 this.isClosed = true; 1871 1872 if (sqlEx != null) { 1873 throw sqlEx; 1874 } 1875 } 1876 1877 1885 synchronized SingleByteCharsetConverter getCharsetConverter( 1886 String javaEncodingName) { 1887 SingleByteCharsetConverter converter = (SingleByteCharsetConverter) this.charsetConverterMap 1888 .get(javaEncodingName); 1889 1890 if (converter == CHARSET_CONVERTER_NOT_AVAILABLE_MARKER) { 1891 return null; 1892 } 1893 1894 if (converter == null) { 1895 try { 1896 converter = SingleByteCharsetConverter.getInstance(javaEncodingName); 1897 1898 if (converter == null) { 1899 this.charsetConverterMap.put(javaEncodingName, 1900 CHARSET_CONVERTER_NOT_AVAILABLE_MARKER); 1901 } 1902 1903 this.charsetConverterMap.put(javaEncodingName, converter); 1904 } catch (UnsupportedEncodingException unsupEncEx) { 1905 this.charsetConverterMap.put(javaEncodingName, 1906 CHARSET_CONVERTER_NOT_AVAILABLE_MARKER); 1907 1908 converter = null; 1909 } 1910 } 1911 1912 return converter; 1913 } 1914 1915 1920 int getMaxAllowedPacket() { 1921 return this.maxAllowedPacket; 1922 } 1923 1924 1929 int getMaxRows() { 1930 return this.maxRows; 1931 } 1932 1933 1940 Object getMutex() throws SQLException { 1941 if (this.io == null) { 1942 throw new SQLException ("Connection.close() has already been called. Invalid operation in this state.", 1943 "08003"); 1944 } 1945 1946 return this.mutex; 1947 } 1948 1949 1954 int getNetBufferLength() { 1955 return this.netBufferLength; 1956 } 1957 1958 boolean isPedantic() { 1959 return this.pedantic; 1960 } 1961 1962 void setReadInfoMsgEnabled(boolean flag) { 1963 this.readInfoMsg = flag; 1964 } 1965 1966 boolean isReadInfoMsgEnabled() { 1967 return this.readInfoMsg; 1968 } 1969 1970 int getServerMajorVersion() { 1971 return this.io.getServerMajorVersion(); 1972 } 1973 1974 int getServerMinorVersion() { 1975 return this.io.getServerMinorVersion(); 1976 } 1977 1978 int getServerSubMinorVersion() { 1979 return this.io.getServerSubMinorVersion(); 1980 } 1981 1982 String getServerVersion() { 1983 return this.io.getServerVersion(); 1984 } 1985 1986 String getURL() { 1987 return this.myURL; 1988 } 1989 1990 1995 void setUseSSL(boolean flag) { 1996 this.useSSL = flag; 1997 } 1998 1999 String getUser() { 2000 return this.user; 2001 } 2002 2003 boolean alwaysClearStream() { 2004 return this.alwaysClearStream; 2005 } 2006 2007 boolean continueBatchOnError() { 2008 return this.continueBatchOnError; 2009 } 2010 2011 2023 ResultSet execSQL(String sql, int maxRowsToRetreive, String catalog) 2024 throws java.sql.SQLException { 2025 if (Driver.TRACE) { 2026 Object [] args = { sql, new Integer (maxRowsToRetreive) }; 2027 Debug.methodCall(this, "execSQL", args); 2028 } 2029 2030 return execSQL(sql, maxRowsToRetreive, null, 2031 java.sql.ResultSet.CONCUR_READ_ONLY, catalog); 2032 } 2033 2034 ResultSet execSQL(String sql, int maxRows, int resultSetType, 2035 boolean streamResults, boolean queryIsSelectOnly, String catalog) 2036 throws SQLException { 2037 return execSQL(sql, maxRows, null, resultSetType, streamResults, 2038 queryIsSelectOnly, catalog); 2039 } 2040 2041 ResultSet execSQL(String sql, int maxRows, Buffer packet, String catalog) 2042 throws java.sql.SQLException { 2043 return execSQL(sql, maxRows, packet, 2044 java.sql.ResultSet.CONCUR_READ_ONLY, catalog); 2045 } 2046 2047 ResultSet execSQL(String sql, int maxRows, Buffer packet, 2048 int resultSetType, String catalog) throws java.sql.SQLException { 2049 return execSQL(sql, maxRows, packet, resultSetType, true, false, catalog); 2050 } 2051 2052 ResultSet execSQL(String sql, int maxRows, Buffer packet, 2053 int resultSetType, boolean streamResults, boolean queryIsSelectOnly, 2054 String catalog) throws java.sql.SQLException { 2055 if (Driver.TRACE) { 2056 Object [] args = { sql, new Integer (maxRows), packet }; 2057 Debug.methodCall(this, "execSQL", args); 2058 } 2059 2060 if ((sql == null) || (sql.length() == 0)) { 2061 if (packet == null) { 2062 throw new SQLException ("Query can not be null or empty", 2063 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 2064 } 2065 } 2066 2067 synchronized (this.mutex) { 2073 this.lastQueryFinishedTime = 0; 2075 pingAndReconnect(false); 2076 2077 try { 2078 int realMaxRows = (maxRows == -1) ? MysqlDefs.MAX_ROWS : maxRows; 2079 2080 if (packet == null) { 2081 String encoding = null; 2082 2083 if (useUnicode()) { 2084 encoding = getEncoding(); 2085 } 2086 2087 return this.io.sqlQuery(sql, realMaxRows, encoding, this, 2088 resultSetType, streamResults, catalog); 2089 } else { 2090 return this.io.sqlQueryDirect(packet, realMaxRows, this, 2091 resultSetType, streamResults, catalog); 2092 } 2093 } catch (java.sql.SQLException sqlE) { 2094 String sqlState = sqlE.getSQLState(); 2096 2097 if ((sqlState != null) 2098 && sqlState.equals( 2099 SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE)) { 2100 cleanup(sqlE); 2101 } 2102 2103 throw sqlE; 2104 } catch (Exception ex) { 2105 if (ex instanceof IOException ) { 2106 cleanup(ex); 2107 } 2108 2109 String exceptionType = ex.getClass().getName(); 2110 String exceptionMessage = ex.getMessage(); 2111 2112 if (!this.useParanoidErrorMessages()) { 2113 exceptionMessage += "\n\nNested Stack Trace:\n"; 2114 exceptionMessage += Util.stackTraceToString(ex); 2115 } 2116 2117 throw new java.sql.SQLException ( 2118 "Error during query: Unexpected Exception: " 2119 + exceptionType + " message given: " + exceptionMessage, 2120 SQLError.SQL_STATE_GENERAL_ERROR); 2121 } finally { 2122 this.lastQueryFinishedTime = System.currentTimeMillis(); 2123 } 2124 } 2125 } 2126 2127 2132 void maxRowsChanged(Statement stmt) { 2133 synchronized (this.mutex) { 2134 if (this.statementsUsingMaxRows == null) { 2135 this.statementsUsingMaxRows = new HashMap (); 2136 } 2137 2138 this.statementsUsingMaxRows.put(stmt, stmt); 2139 2140 this.maxRowsChanged = true; 2141 } 2142 } 2143 2144 2153 void unsetMaxRows(Statement stmt) throws SQLException { 2154 synchronized (this.mutex) { 2155 if (this.statementsUsingMaxRows != null) { 2156 Object found = this.statementsUsingMaxRows.remove(stmt); 2157 2158 if ((found != null) 2159 && (this.statementsUsingMaxRows.size() == 0)) { 2160 execSQL("SET OPTION SQL_SELECT_LIMIT=DEFAULT", -1, 2161 this.database); 2162 this.maxRowsChanged = false; 2163 } 2164 } 2165 } 2166 } 2167 2168 boolean useAnsiQuotedIdentifiers() { 2169 return this.useAnsiQuotes; 2170 } 2171 2172 boolean useHostsInPrivileges() { 2173 return this.useHostsInPrivileges; 2174 } 2175 2176 2181 boolean useMaxRows() { 2182 synchronized (this.mutex) { 2183 return this.maxRowsChanged; 2184 } 2185 } 2186 2187 boolean useStreamLengthsInPrepStmts() { 2188 return this.useStreamLengthsInPrepStmts; 2189 } 2190 2191 2196 private void setFailedOverState() throws SQLException { 2197 setReadOnly(true); 2199 this.queriesIssuedFailedOver = 0; 2200 this.failedOver = true; 2201 this.masterFailTimeMillis = System.currentTimeMillis(); 2202 } 2203 2204 private void checkClosed() throws SQLException { 2205 if (this.isClosed) { 2206 StringBuffer exceptionMessage = new StringBuffer (); 2207 2208 exceptionMessage.append( 2209 "No operations allowed after connection closed."); 2210 2211 if (!this.paranoid) { 2212 if (this.forcedCloseReason != null) { 2213 exceptionMessage.append( 2214 "\n\nConnection was closed due to the following exception:"); 2215 exceptionMessage.append(Util.stackTraceToString( 2216 this.forcedCloseReason)); 2217 } else if (this.explicitCloseLocation != null) { 2218 exceptionMessage.append( 2219 "\n\nConnection was closed explicitly by the application at the following location:"); 2220 exceptionMessage.append(Util.stackTraceToString( 2221 this.explicitCloseLocation)); 2222 } 2223 } 2224 2225 throw new SQLException (exceptionMessage.toString(), "08003"); 2226 } 2227 } 2228 2229 2235 private void checkServerEncoding() throws SQLException { 2236 if (this.doUnicode && (this.encoding != null)) { 2237 if (!this.io.versionMeetsMinimum(4, 1, 0)) { 2241 if ("ISO8859_2".equals("this.encoding")) { 2242 throw new SQLException ( 2243 "Character encoding 'ISO8859_2' specified in JDBC URL which maps to multiple MySQL character encodings:" 2244 + "\n\n" + "* 'latin2'\n" + "* 'czech'\n" 2245 + "* 'hungarian'\n" + "* 'croat'\n" 2246 + "\nSpecify one of the above encodings using the 'mysqlEncoding' connection property.", 2247 SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE); 2248 } else if ("ISO8859_13".equals("this.encoding")) { 2249 throw new SQLException ( 2250 "Character encoding 'ISO8859_13' specified in JDBC URL which maps to multiple MySQL character encodings:" 2251 + "\n\n" + "* 'latvian'\n" + "* 'latvian1'\n" 2252 + "* 'estonia'\n" 2253 + "\nSpecify one of the above encodings using the 'mysqlEncoding' connection property.", 2254 SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE); 2255 } 2256 } 2257 2258 return; 2259 } 2260 2261 this.mysqlEncodingName = (String ) this.serverVariables.get( 2262 "character_set"); 2263 2264 if (this.mysqlEncodingName == null) { 2265 this.mysqlEncodingName = (String ) this.serverVariables.get( 2267 "character_set_client"); 2268 } 2269 2270 String javaEncodingName = null; 2271 2272 if (this.mysqlEncodingName != null) { 2273 javaEncodingName = (String ) charsetMap.get(this.mysqlEncodingName 2274 .toUpperCase()); 2275 } 2276 2277 if (!this.doUnicode && (javaEncodingName != null)) { 2281 SingleByteCharsetConverter converter = getCharsetConverter(javaEncodingName); 2282 2283 if (converter != null) { this.doUnicode = true; this.encoding = javaEncodingName; 2286 2287 return; 2288 } 2289 } 2290 2291 if (this.mysqlEncodingName != null) { 2296 if (javaEncodingName == null) { 2297 if (Character.isLowerCase(this.mysqlEncodingName.charAt(0))) { 2300 char[] ach = this.mysqlEncodingName.toCharArray(); 2301 ach[0] = Character.toUpperCase(this.mysqlEncodingName 2302 .charAt(0)); 2303 this.encoding = new String (ach); 2304 } 2305 } 2306 2307 try { 2312 "abc".getBytes(javaEncodingName); 2313 this.encoding = javaEncodingName; 2314 this.doUnicode = true; 2315 } catch (UnsupportedEncodingException UE) { 2316 throw new SQLException ( 2317 "The driver can not map the character encoding '" 2318 + this.encoding + "' that your server is using " 2319 + "to a character encoding your JVM understands. You " 2320 + "can specify this mapping manually by adding \"useUnicode=true\" " 2321 + "as well as \"characterEncoding=[an_encoding_your_jvm_understands]\" " 2322 + "to your JDBC URL.", 2323 SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE); 2324 } 2325 } 2326 } 2327 2328 2334 private void checkTransactionIsolationLevel() throws SQLException { 2335 String txIsolationName = null; 2336 2337 if (this.io.versionMeetsMinimum(4, 0, 3)) { 2338 txIsolationName = "tx_isolation"; 2339 } else { 2340 txIsolationName = "transaction_isolation"; 2341 } 2342 2343 String s = (String ) this.serverVariables.get(txIsolationName); 2344 2345 if (s != null) { 2346 Integer intTI = (Integer ) mapTransIsolationName2Value.get(s); 2347 2348 if (intTI != null) { 2349 isolationLevel = intTI.intValue(); 2350 } 2351 } 2352 } 2353 2354 2359 private void cleanup(Throwable cleanupReason) { 2360 try { 2361 if ((this.io != null) && !isClosed()) { 2362 realClose(false, false); 2363 } else if (this.io != null) { 2364 this.io.forceClose(); 2365 } 2366 } catch (SQLException sqlEx) { 2367 } 2369 2370 this.isClosed = true; 2371 this.forcedCloseReason = cleanupReason; 2372 } 2373 2374 private void detectFloatingPointStyle() throws SQLException { 2375 java.sql.Statement stmt = null; 2376 java.sql.ResultSet rs = null; 2377 2378 try { 2379 stmt = createStatement(); 2380 2381 if (stmt.getMaxRows() != 0) { 2382 stmt.setMaxRows(0); 2383 } 2384 2385 rs = stmt.executeQuery( 2386 "select round('inf'), round('-inf'), round('nan')"); 2387 2388 if (rs.next()) { 2389 String posInf = rs.getString(1); 2390 2391 if ("inf".equalsIgnoreCase(posInf)) { 2392 this.positiveInfinityRep = "'inf'"; 2393 this.positiveInfinityRepIsClipped = false; 2394 } 2395 2396 String negInf = rs.getString(2); 2397 2398 if ("-inf".equalsIgnoreCase(negInf)) { 2399 this.negativeInfinityRep = "'-inf'"; 2400 this.negativeInfinityRepIsClipped = false; 2401 } 2402 2403 String nan = rs.getString(3); 2404 2405 if ("nan".equalsIgnoreCase(nan)) { 2406 this.notANumberRep = "'nan'"; 2407 this.notANumberRepIsClipped = false; 2408 } 2409 } 2410 2411 rs.close(); 2412 rs = null; 2413 2414 stmt.close(); 2415 stmt = null; 2416 } catch (SQLException sqlEx) { 2417 ; } finally { 2419 if (rs != null) { 2420 try { 2421 rs.close(); 2422 } catch (SQLException sqlEx) { 2423 ; } 2425 2426 rs = null; 2427 } 2428 2429 if (stmt != null) { 2430 try { 2431 stmt.close(); 2432 } catch (SQLException sqlEx) { 2433 ; } 2435 2436 stmt = null; 2437 } 2438 } 2439 } 2440 2441 2449 private void initializeDriverProperties(Properties info) 2450 throws SQLException { 2451 this.socketFactoryClassName = info.getProperty("socketFactory", 2452 DEFAULT_SOCKET_FACTORY); 2453 2454 this.useUnbufferedInput = "TRUE".equalsIgnoreCase(info.getProperty( 2455 "useUnbufferedInput")); 2456 2457 if (info.getProperty("cachePrepStmts") != null) { 2458 this.cachePreparedStatements = info.getProperty("cachePrepStmts") 2459 .equalsIgnoreCase("TRUE"); 2460 2461 if (this.cachePreparedStatements) { 2462 if (info.getProperty("prepStmtCacheSize") != null) { 2463 try { 2464 this.preparedStatementCacheSize = Integer.parseInt(info 2465 .getProperty("prepStmtCacheSize")); 2466 2467 if (this.preparedStatementCacheSize < 0) { 2468 throw new SQLException ("Connection property 'prepStmtCacheSize' must be a non-negative integer value.", 2469 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 2470 } 2471 } catch (NumberFormatException nfe) { 2472 throw new SQLException ("Connection property 'prepStmtCacheSize' must be a non-negative integer value.", 2473 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 2474 } 2475 } 2476 2477 if (info.getProperty("prepStmtCacheSqlLimit") != null) { 2478 try { 2479 this.preparedStatementCacheMaxSqlSize = Integer 2480 .parseInt(info.getProperty("prepStmtCacheSqlLimit")); 2481 2482 if (this.preparedStatementCacheMaxSqlSize < 0) { 2483 throw new SQLException ("Connection property 'prepStmtCacheSqlLimit' must be a non-negative integer value.", 2484 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 2485 } 2486 } catch (NumberFormatException nfe) { 2487 throw new SQLException ("Connection property 'prepStmtCacheSqlLimit' must be a non-negative integer value.", 2488 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 2489 } 2490 } 2491 2492 this.cachedPreparedStatementParams = new HashMap (this.preparedStatementCacheSize); 2493 } 2494 } 2495 2496 if (info.getProperty("alwaysClearStream") != null) { 2497 this.alwaysClearStream = info.getProperty("alwaysClearStream") 2498 .equalsIgnoreCase("TRUE"); 2499 } 2500 2501 if (info.getProperty("reconnectAtTxEnd") != null) { 2502 this.reconnectAtTxEnd = info.getProperty("reconnectAtTxEnd") 2503 .equalsIgnoreCase("TRUE"); 2504 } 2505 2506 if (info.getProperty("clobberStreamingResults") != null) { 2507 this.clobberStreamingResults = info.getProperty( 2508 "clobberStreamingResults").equalsIgnoreCase("TRUE"); 2509 } 2510 2511 if (info.getProperty("strictUpdates") != null) { 2512 this.strictUpdates = info.getProperty("strictUpdates") 2513 .equalsIgnoreCase("TRUE"); 2514 } 2515 2516 if (info.getProperty("ignoreNonTxTables") != null) { 2517 this.ignoreNonTxTables = info.getProperty("ignoreNonTxTables") 2518 .equalsIgnoreCase("TRUE"); 2519 } 2520 2521 if (info.getProperty("secondsBeforeRetryMaster") != null) { 2522 String secondsBeforeRetryStr = info.getProperty( 2523 "secondsBeforeRetryMaster"); 2524 2525 try { 2526 int seconds = Integer.parseInt(secondsBeforeRetryStr); 2527 2528 if (seconds < 1) { 2529 throw new SQLException ("Illegal (< 1) value '" 2530 + secondsBeforeRetryStr 2531 + "' for 'secondsBeforeRetryMaster'", 2532 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 2533 } 2534 2535 this.secondsBeforeRetryMaster = seconds; 2536 } catch (NumberFormatException nfe) { 2537 throw new SQLException ("Illegal non-numeric value '" 2538 + secondsBeforeRetryStr 2539 + "' for 'secondsBeforeRetryMaster'", 2540 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 2541 } 2542 } 2543 2544 if (info.getProperty("queriesBeforeRetryMaster") != null) { 2545 String queriesBeforeRetryStr = info.getProperty( 2546 "queriesBeforeRetryMaster"); 2547 2548 try { 2549 this.queriesBeforeRetryMaster = Integer.parseInt(queriesBeforeRetryStr); 2550 } catch (NumberFormatException nfe) { 2551 throw new SQLException ("Illegal non-numeric value '" 2552 + queriesBeforeRetryStr 2553 + "' for 'queriesBeforeRetryMaster'", 2554 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 2555 } 2556 } 2557 2558 if (info.getProperty("allowLoadLocalInfile") != null) { 2559 this.allowLoadLocalInfile = info.getProperty("allowLoadLocalInfile") 2560 .equalsIgnoreCase("TRUE"); 2561 } 2562 2563 if (info.getProperty("continueBatchOnError") != null) { 2564 this.continueBatchOnError = info.getProperty("continueBatchOnError") 2565 .equalsIgnoreCase("TRUE"); 2566 } 2567 2568 if (info.getProperty("pedantic") != null) { 2569 this.pedantic = info.getProperty("pedantic").equalsIgnoreCase("TRUE"); 2570 } 2571 2572 if (info.getProperty("useStreamLengthsInPrepStmts") != null) { 2573 this.useStreamLengthsInPrepStmts = info.getProperty( 2574 "useStreamLengthsInPrepStmts").equalsIgnoreCase("TRUE"); 2575 } 2576 2577 if (info.getProperty("useTimezone") != null) { 2578 this.useTimezone = info.getProperty("useTimezone").equalsIgnoreCase("TRUE"); 2579 } 2580 2581 if (info.getProperty("relaxAutoCommit") != null) { 2582 this.relaxAutoCommit = info.getProperty("relaxAutoCommit") 2583 .equalsIgnoreCase("TRUE"); 2584 } else if (info.getProperty("relaxAutocommit") != null) { 2585 this.relaxAutoCommit = info.getProperty("relaxAutocommit") 2586 .equalsIgnoreCase("TRUE"); 2587 } 2588 2589 if (info.getProperty("paranoid") != null) { 2590 this.paranoid = info.getProperty("paranoid").equalsIgnoreCase("TRUE"); 2591 } 2592 2593 if (info.getProperty("autoReconnect") != null) { 2594 this.highAvailability = info.getProperty("autoReconnect") 2595 .equalsIgnoreCase("TRUE"); 2596 } 2597 2598 if (info.getProperty("capitalizeTypeNames") != null) { 2599 this.capitalizeDBMDTypes = info.getProperty("capitalizeTypeNames") 2600 .equalsIgnoreCase("TRUE"); 2601 } 2602 2603 if (info.getProperty("ultraDevHack") != null) { 2604 this.useUltraDevWorkAround = info.getProperty("ultraDevHack") 2605 .equalsIgnoreCase("TRUE"); 2606 } 2607 2608 if (info.getProperty("strictFloatingPoint") != null) { 2609 this.strictFloatingPoint = info.getProperty("strictFloatingPoint") 2610 .equalsIgnoreCase("TRUE"); 2611 } 2612 2613 if (info.getProperty("useSSL") != null) { 2614 this.useSSL = info.getProperty("useSSL").equalsIgnoreCase("TRUE"); 2615 } 2616 2617 if (info.getProperty("useCompression") != null) { 2618 this.useCompression = info.getProperty("useCompression") 2619 .equalsIgnoreCase("TRUE"); 2620 } 2621 2622 if (info.getProperty("socketTimeout") != null) { 2623 try { 2624 int n = Integer.parseInt(info.getProperty("socketTimeout")); 2625 2626 if (n < 0) { 2627 throw new SQLException ("socketTimeout can not " + "be < 0", 2628 SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE); 2629 } 2630 2631 this.socketTimeout = n; 2632 } catch (NumberFormatException NFE) { 2633 throw new SQLException ("Illegal parameter '" 2634 + info.getProperty("socketTimeout") + "' for socketTimeout", 2635 SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE); 2636 } 2637 } 2638 2639 if (this.highAvailability) { 2640 if (info.getProperty("maxReconnects") != null) { 2641 try { 2642 int n = Integer.parseInt(info.getProperty("maxReconnects")); 2643 this.maxReconnects = n; 2644 } catch (NumberFormatException NFE) { 2645 throw new SQLException ("Illegal parameter '" 2646 + info.getProperty("maxReconnects") 2647 + "' for maxReconnects", 2648 SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE); 2649 } 2650 } 2651 2652 if (info.getProperty("initialTimeout") != null) { 2653 try { 2654 double n = Integer.parseInt(info.getProperty( 2655 "initialTimeout")); 2656 this.initialTimeout = n; 2657 } catch (NumberFormatException NFE) { 2658 throw new SQLException ("Illegal parameter '" 2659 + info.getProperty("initialTimeout") 2660 + "' for initialTimeout", 2661 SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE); 2662 } 2663 } 2664 } 2665 2666 if (info.getProperty("maxRows") != null) { 2667 try { 2668 int n = Integer.parseInt(info.getProperty("maxRows")); 2669 2670 if (n == 0) { 2671 n = -1; 2672 } 2673 2674 this.maxRows = n; 2677 this.maxRowsChanged = true; 2678 } catch (NumberFormatException NFE) { 2679 throw new SQLException ("Illegal parameter '" 2680 + info.getProperty("maxRows") + "' for maxRows", 2681 SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE); 2682 } 2683 } 2684 2685 if (info.getProperty("useHostsInPrivileges") != null) { 2686 this.useHostsInPrivileges = info.getProperty("useHostsInPrivileges") 2687 .equalsIgnoreCase("TRUE"); 2688 } 2689 2690 if (info.getProperty("interactiveClient") != null) { 2691 this.isInteractiveClient = info.getProperty("interactiveClient") 2692 .equalsIgnoreCase("TRUE"); 2693 } 2694 2695 if (info.getProperty("useUnicode") != null) { 2696 this.doUnicode = info.getProperty("useUnicode").equalsIgnoreCase("TRUE"); 2697 } 2698 2699 if (this.doUnicode) { 2700 if (info.getProperty("mysqlEncoding") != null) { 2701 this.mysqlEncodingName = info.getProperty("mysqlEncoding"); 2702 } 2703 2704 if (info.getProperty("characterEncoding") != null) { 2705 this.encoding = info.getProperty("characterEncoding"); 2706 2707 try { 2710 String testString = "abc"; 2711 testString.getBytes(this.encoding); 2712 } catch (UnsupportedEncodingException UE) { 2713 throw new SQLException ("Unsupported character " 2714 + "encoding '" + this.encoding + "'.", 2715 SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE); 2716 } 2717 } 2718 } 2719 } 2720 2721 2729 private void initializePropsFromServer(Properties info) 2730 throws SQLException { 2731 if (this.io.versionMeetsMinimum(3, 22, 1)) { 2732 this.useFastPing = true; 2733 } 2734 2735 detectFloatingPointStyle(); 2736 2737 this.serverVariables.clear(); 2738 2739 if (this.io.versionMeetsMinimum(3, 21, 22)) { 2743 com.mysql.jdbc.Statement stmt = null; 2744 com.mysql.jdbc.ResultSet results = null; 2745 2746 try { 2747 stmt = (com.mysql.jdbc.Statement) createStatement(); 2748 2749 if (stmt.getMaxRows() != 0) { 2750 stmt.setMaxRows(0); 2751 } 2752 2753 results = (com.mysql.jdbc.ResultSet) stmt.executeQuery( 2754 "SHOW VARIABLES"); 2755 2756 while (results.next()) { 2757 this.serverVariables.put(results.getString(1), 2758 results.getString(2)); 2759 } 2760 } catch (java.sql.SQLException e) { 2761 throw e; 2762 } finally { 2763 if (results != null) { 2764 try { 2765 results.close(); 2766 } catch (java.sql.SQLException sqlE) { 2767 ; 2768 } 2769 } 2770 2771 if (stmt != null) { 2772 try { 2773 stmt.close(); 2774 } catch (java.sql.SQLException sqlE) { 2775 ; 2776 } 2777 } 2778 } 2779 2780 String lowerCaseTables = (String ) serverVariables.get( 2781 "lower_case_table_names"); 2782 2783 this.lowerCaseTableNames = "on".equalsIgnoreCase(lowerCaseTables) 2784 || "1".equalsIgnoreCase(lowerCaseTables) 2785 || "2".equalsIgnoreCase(lowerCaseTables); 2786 2787 if (this.useTimezone 2788 && this.serverVariables.containsKey("timezone")) { 2789 String canoncicalTimezone = this.props.getProperty( 2791 "serverTimezone"); 2792 2793 if ((canoncicalTimezone == null) 2794 || (canoncicalTimezone.length() == 0)) { 2795 String serverTimezoneStr = (String ) this.serverVariables 2796 .get("timezone"); 2797 2798 try { 2799 canoncicalTimezone = TimeUtil.getCanoncialTimezone(serverTimezoneStr); 2800 2801 if (canoncicalTimezone == null) { 2802 throw new SQLException ("Can't map timezone '" 2803 + serverTimezoneStr + "' to " 2804 + " canonical timezone.", 2805 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 2806 } 2807 } catch (IllegalArgumentException iae) { 2808 throw new SQLException (iae.getMessage(), 2809 SQLError.SQL_STATE_GENERAL_ERROR); 2810 } 2811 } 2812 2813 serverTimezone = TimeZone.getTimeZone(canoncicalTimezone); 2814 2815 if (!canoncicalTimezone.equalsIgnoreCase("GMT") 2821 && serverTimezone.getID().equals("GMT")) { 2822 throw new SQLException ("No timezone mapping entry for '" 2823 + canoncicalTimezone + "'", 2824 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 2825 } 2826 } 2827 2828 if (this.serverVariables.containsKey("max_allowed_packet")) { 2829 this.maxAllowedPacket = Integer.parseInt((String ) this.serverVariables 2830 .get("max_allowed_packet")); 2831 } 2832 2833 if (this.serverVariables.containsKey("net_buffer_length")) { 2834 this.netBufferLength = Integer.parseInt((String ) this.serverVariables 2835 .get("net_buffer_length")); 2836 } 2837 2838 checkTransactionIsolationLevel(); 2839 checkServerEncoding(); 2840 this.io.checkForCharsetMismatch(); 2841 } 2842 2843 if (this.io.versionMeetsMinimum(3, 23, 15)) { 2844 this.transactionsSupported = true; 2845 setAutoCommit(true); } else { 2849 this.transactionsSupported = false; 2850 } 2851 2852 if (this.io.versionMeetsMinimum(3, 23, 36)) { 2853 this.hasIsolationLevels = true; 2854 } else { 2855 this.hasIsolationLevels = false; 2856 } 2857 2858 String profileSql = info.getProperty("profileSql"); 2860 2861 if ((profileSql != null) && profileSql.trim().equalsIgnoreCase("true")) { 2862 this.io.setProfileSql(true); 2863 } else { 2864 this.io.setProfileSql(false); 2865 } 2866 2867 this.hasQuotedIdentifiers = this.io.versionMeetsMinimum(3, 23, 6); 2868 2869 if (this.serverVariables.containsKey("sql_mode")) { 2870 int sqlMode = 0; 2871 2872 try { 2873 sqlMode = Integer.parseInt((String ) this.serverVariables.get( 2874 "sql_mode")); 2875 } catch (NumberFormatException nfe) { 2876 sqlMode = 0; 2877 } 2878 2879 if ((sqlMode & 4) > 0) { 2880 this.useAnsiQuotes = true; 2881 } else { 2882 this.useAnsiQuotes = false; 2883 } 2884 } 2885 2886 if (this.io.versionMeetsMinimum(4, 1, 0) && useUnicode() 2890 && (getEncoding() != null)) { 2891 if (getEncoding().equalsIgnoreCase("UTF-8") 2892 || getEncoding().equalsIgnoreCase("UTF8")) { 2893 execSQL("SET NAMES utf8", -1, this.database); 2895 } else { 2896 String namesEncoding = this.mysqlEncodingName; 2897 2898 if ("koi8_ru".equals(this.mysqlEncodingName)) { 2899 namesEncoding = "ko18r"; 2901 } 2902 2903 if (namesEncoding != null) { 2904 execSQL("SET NAMES " + namesEncoding, -1, this.database); 2905 } 2906 } 2907 } 2908 2909 this.io.resetMaxBuf(); 2910 } 2911 2912 2915 private static void loadCharacterSetMapping() { 2916 multibyteCharsetsMap = new HashMap (); 2917 2918 Iterator multibyteCharsets = CharsetMapping.MULTIBYTE_CHARSETS.keySet() 2919 .iterator(); 2920 2921 while (multibyteCharsets.hasNext()) { 2922 String charset = ((String ) multibyteCharsets.next()).toUpperCase(); 2923 multibyteCharsetsMap.put(charset, charset); 2924 } 2925 2926 Iterator keys = CharsetMapping.CHARSETMAP.keySet().iterator(); 2931 charsetMap = new HashMap (); 2932 2933 while (keys.hasNext()) { 2934 String mysqlCharsetName = ((String ) keys.next()).trim(); 2935 String javaCharsetName = CharsetMapping.CHARSETMAP.get(mysqlCharsetName) 2936 .toString().trim(); 2937 charsetMap.put(mysqlCharsetName.toUpperCase(), javaCharsetName); 2938 charsetMap.put(mysqlCharsetName, javaCharsetName); 2939 } 2940 } 2941 2942 private boolean getUseUltraDevWorkAround() { 2943 return useUltraDevWorkAround; 2944 } 2945 2946 2952 2957 private void ping() throws Exception { 2958 if (this.useFastPing) { 2959 this.io.sendCommand(MysqlDefs.PING, null, null); 2960 } else { 2961 this.io.sqlQuery(PING_COMMAND, MysqlDefs.MAX_ROWS, this.encoding, 2962 this, java.sql.ResultSet.CONCUR_READ_ONLY, false, this.database); 2963 } 2964 } 2965 2966 private void pingAndReconnect(boolean ignoreAutoCommitSetting) 2967 throws SQLException { 2968 boolean localAutoCommit = this.autoCommit; 2969 2970 if (ignoreAutoCommitSetting) { 2974 localAutoCommit = true; 2975 } 2976 2977 if (this.failedOver && localAutoCommit) { 2978 this.queriesIssuedFailedOver++; 2979 2980 if (shouldFallBack()) { 2981 createNewIO(true); 2982 2983 String connectedHost = this.io.getHost(); 2984 2985 if ((connectedHost != null) 2986 && this.hostList.get(0).equals(connectedHost)) { 2987 this.failedOver = false; 2988 this.queriesIssuedFailedOver = 0; 2989 setReadOnly(false); 2990 } 2991 } 2992 } 2993 2994 if ((this.highAvailability || this.failedOver) && localAutoCommit) { 2995 try { 2996 ping(); 2997 } catch (Exception Ex) { 2998 createNewIO(true); 2999 } 3000 } 3001 } 3002 3003 private void rollbackNoChecks() throws SQLException { 3004 execSQL("rollback", -1, null); 3005 } 3006 3007 3014 private boolean shouldFallBack() { 3015 long secondsSinceFailedOver = (System.currentTimeMillis() 3016 - this.masterFailTimeMillis) / 1000; 3017 3018 return ((secondsSinceFailedOver >= this.secondsBeforeRetryMaster) 3019 || ((this.queriesIssuedFailedOver % this.queriesBeforeRetryMaster) == 0)); 3020 } 3021 3022 3026 class UltraDevWorkAround implements java.sql.CallableStatement { 3027 private java.sql.PreparedStatement delegate = null; 3028 3029 UltraDevWorkAround(java.sql.PreparedStatement pstmt) { 3030 delegate = pstmt; 3031 } 3032 3033 public void setArray(int p1, final java.sql.Array p2) 3034 throws java.sql.SQLException { 3035 delegate.setArray(p1, p2); 3036 } 3037 3038 public java.sql.Array getArray(int p1) throws java.sql.SQLException { 3039 throw new SQLException ("Not supported"); 3040 } 3041 3042 3045 public java.sql.Array getArray(String arg0) throws SQLException { 3046 throw new NotImplemented(); 3047 } 3048 3049 public void setAsciiStream(int p1, final java.io.InputStream p2, int p3) 3050 throws java.sql.SQLException { 3051 delegate.setAsciiStream(p1, p2, p3); 3052 } 3053 3054 3057 public void setAsciiStream(String arg0, InputStream arg1, int arg2) 3058 throws SQLException { 3059 throw new NotImplemented(); 3060 } 3061 3062 public void setBigDecimal(int p1, final java.math.BigDecimal p2) 3063 throws java.sql.SQLException { 3064 delegate.setBigDecimal(p1, p2); 3065 } 3066 3067 3070 public void setBigDecimal(String arg0, BigDecimal arg1) 3071 throws SQLException { 3072 throw new NotImplemented(); 3073 } 3074 3075 public java.math.BigDecimal getBigDecimal(int p1) 3076 throws java.sql.SQLException { 3077 throw new SQLException ("Not supported"); 3078 } 3079 3080 public java.math.BigDecimal getBigDecimal(int p1, int p2) 3081 throws java.sql.SQLException { 3082 throw new SQLException ("Not supported"); 3083 } 3084 3085 3088 public BigDecimal getBigDecimal(String arg0) throws SQLException { 3089 return null; 3090 } 3091 3092 public void setBinaryStream(int p1, final java.io.InputStream p2, int p3) 3093 throws java.sql.SQLException { 3094 delegate.setBinaryStream(p1, p2, p3); 3095 } 3096 3097 3100 public void setBinaryStream(String arg0, InputStream arg1, int arg2) 3101 throws SQLException { 3102 throw new NotImplemented(); 3103 } 3104 3105 public void setBlob(int p1, final java.sql.Blob p2) 3106 throws java.sql.SQLException { 3107 delegate.setBlob(p1, p2); 3108 } 3109 3110 public java.sql.Blob getBlob(int p1) throws java.sql.SQLException { 3111 throw new SQLException ("Not supported"); 3112 } 3113 3114 3117 public java.sql.Blob getBlob(String arg0) throws SQLException { 3118 throw new NotImplemented(); 3119 } 3120 3121 public void setBoolean(int p1, boolean p2) throws java.sql.SQLException { 3122 delegate.setBoolean(p1, p2); 3123 } 3124 3125 3128 public void setBoolean(String arg0, boolean arg1) 3129 throws SQLException { 3130 throw new NotImplemented(); 3131 } 3132 3133 public boolean getBoolean(int p1) throws java.sql.SQLException { 3134 throw new SQLException ("Not supported"); 3135 } 3136 3137 3140 public boolean getBoolean(String arg0) throws SQLException { 3141 throw new NotImplemented(); 3142 } 3143 3144 public void setByte(int p1, byte p2) throws java.sql.SQLException { 3145 delegate.setByte(p1, p2); 3146 } 3147 3148 3151 public void setByte(String arg0, byte arg1) throws SQLException { 3152 throw new NotImplemented(); 3153 } 3154 3155 public byte getByte(int p1) throws java.sql.SQLException { 3156 throw new SQLException ("Not supported"); 3157 } 3158 3159 3162 public byte getByte(String arg0) throws SQLException { 3163 throw new NotImplemented(); 3164 } 3165 3166 public void setBytes(int p1, byte[] p2) throws java.sql.SQLException { 3167 delegate.setBytes(p1, p2); 3168 } 3169 3170 3173 public void setBytes(String arg0, byte[] arg1) 3174 throws SQLException { 3175 throw new NotImplemented(); 3176 } 3177 3178 public byte[] getBytes(int p1) throws java.sql.SQLException { 3179 throw new SQLException ("Not supported"); 3180 } 3181 3182 3185 public byte[] getBytes(String arg0) throws SQLException { 3186 throw new NotImplemented(); 3187 } 3188 3189 public void setCharacterStream(int p1, final java.io.Reader p2, int p3) 3190 throws java.sql.SQLException { 3191 delegate.setCharacterStream(p1, p2, p3); 3192 } 3193 3194 3197 public void setCharacterStream(String arg0, Reader arg1, int arg2) 3198 throws SQLException { 3199 throw new NotImplemented(); 3200 } 3201 3202 public void setClob(int p1, final java.sql.Clob p2) 3203 throws java.sql.SQLException { 3204 delegate.setClob(p1, p2); 3205 } 3206 3207 public java.sql.Clob getClob(int p1) throws java.sql.SQLException { 3208 throw new SQLException ("Not supported"); 3209 } 3210 3211 3214 public Clob getClob(String arg0) throws SQLException { 3215 throw new NotImplemented(); 3216 } 3217 3218 public java.sql.Connection getConnection() throws java.sql.SQLException { 3219 return delegate.getConnection(); 3220 } 3221 3222 public void setCursorName(java.lang.String p1) 3223 throws java.sql.SQLException { 3224 throw new SQLException ("Not supported"); 3225 } 3226 3227 public void setDate(int p1, final java.sql.Date p2) 3228 throws java.sql.SQLException { 3229 delegate.setDate(p1, p2); 3230 } 3231 3232 public void setDate(int p1, final java.sql.Date p2, 3233 final java.util.Calendar p3) throws java.sql.SQLException { 3234 delegate.setDate(p1, p2, p3); 3235 } 3236 3237 3240 public void setDate(String arg0, Date arg1, Calendar arg2) 3241 throws SQLException { 3242 throw new NotImplemented(); 3243 } 3244 3245 3248 public void setDate(String arg0, Date arg1) throws SQLException { 3249 throw new NotImplemented(); 3250 } 3251 3252 public java.sql.Date getDate(int p1) throws java.sql.SQLException { 3253 throw new SQLException ("Not supported"); 3254 } 3255 3256 public java.sql.Date getDate(int p1, final java.util.Calendar p2) 3257 throws java.sql.SQLException { 3258 throw new SQLException ("Not supported"); 3259 } 3260 3261 3264 public Date getDate(String arg0, Calendar arg1) 3265 throws SQLException { 3266 throw new NotImplemented(); 3267 } 3268 3269 3272 public Date getDate(String arg0) throws SQLException { 3273 throw new NotImplemented(); 3274 } 3275 3276 public void setDouble(int p1, double p2) throws java.sql.SQLException { 3277 delegate.setDouble(p1, p2); 3278 } 3279 3280 3283 public void setDouble(String arg0, double arg1) 3284 throws SQLException { 3285 throw new NotImplemented(); 3286 } 3287 3288 public double getDouble(int p1) throws java.sql.SQLException { 3289 throw new SQLException ("Not supported"); 3290 } 3291 3292 3295 public double getDouble(String arg0) throws SQLException { 3296 throw new NotImplemented(); 3297 } 3298 3299 public void setEscapeProcessing(boolean p1) 3300 throws java.sql.SQLException { 3301 delegate.setEscapeProcessing(p1); 3302 } 3303 3304 public void setFetchDirection(int p1) throws java.sql.SQLException { 3305 delegate.setFetchDirection(p1); 3306 } 3307 3308 public int getFetchDirection() throws java.sql.SQLException { 3309 return delegate.getFetchDirection(); 3310 } 3311 3312 public void setFetchSize(int p1) throws java.sql.SQLException { 3313 delegate.setFetchSize(p1); 3314 } 3315 3316 public int getFetchSize() throws java.sql.SQLException { 3317 return delegate.getFetchSize(); 3318 } 3319 3320 public void setFloat(int p1, float p2) throws java.sql.SQLException { 3321 delegate.setFloat(p1, p2); 3322 } 3323 3324 3327 public void setFloat(String arg0, float arg1) throws SQLException { 3328 throw new NotImplemented(); 3329 } 3330 3331 public float getFloat(int p1) throws java.sql.SQLException { 3332 throw new SQLException ("Not supported"); 3333 } 3334 3335 3338 public float getFloat(String arg0) throws SQLException { 3339 throw new NotImplemented(); 3340 } 3341 3342 3345 public java.sql.ResultSet getGeneratedKeys() throws SQLException { 3346 return delegate.getGeneratedKeys(); 3347 } 3348 3349 public void setInt(int p1, int p2) throws java.sql.SQLException { 3350 delegate.setInt(p1, p2); 3351 } 3352 3353 3356 public void setInt(String arg0, int arg1) throws SQLException { 3357 throw new NotImplemented(); 3358 } 3359 3360 public int getInt(int p1) throws java.sql.SQLException { 3361 throw new SQLException ("Not supported"); 3362 } 3363 3364 3367 public int getInt(String arg0) throws SQLException { 3368 throw new NotImplemented(); 3369 } 3370 3371 public void setLong(int p1, long p2) throws java.sql.SQLException { 3372 delegate.setLong(p1, p2); 3373 } 3374 3375 3378 public void setLong(String arg0, long arg1) throws SQLException { 3379 throw new NotImplemented(); 3380 } 3381 3382 public long getLong(int p1) throws java.sql.SQLException { 3383 throw new SQLException ("Not supported"); 3384 } 3385 3386 3389 public long getLong(String arg0) throws SQLException { 3390 throw new NotImplemented(); 3391 } 3392 3393 public void setMaxFieldSize(int p1) throws java.sql.SQLException { 3394 delegate.setMaxFieldSize(p1); 3395 } 3396 3397 public int getMaxFieldSize() throws java.sql.SQLException { 3398 return delegate.getMaxFieldSize(); 3399 } 3400 3401 public void setMaxRows(int p1) throws java.sql.SQLException { 3402 delegate.setMaxRows(p1); 3403 } 3404 3405 public int getMaxRows() throws java.sql.SQLException { 3406 return delegate.getMaxRows(); 3407 } 3408 3409 public java.sql.ResultSetMetaData getMetaData() 3410 throws java.sql.SQLException { 3411 throw new SQLException ("Not supported"); 3412 } 3413 3414 public boolean getMoreResults() throws java.sql.SQLException { 3415 return delegate.getMoreResults(); 3416 } 3417 3418 3421 public boolean getMoreResults(int arg0) throws SQLException { 3422 return delegate.getMoreResults(); 3423 } 3424 3425 public void setNull(int p1, int p2) throws java.sql.SQLException { 3426 delegate.setNull(p1, p2); 3427 } 3428 3429 public void setNull(int p1, int p2, java.lang.String p3) 3430 throws java.sql.SQLException { 3431 delegate.setNull(p1, p2, p3); 3432 } 3433 3434 3437 public void setNull(String arg0, int arg1, String arg2) 3438 throws SQLException { 3439 throw new NotImplemented(); 3440 } 3441 3442 3445 public void setNull(String arg0, int arg1) throws SQLException { 3446 throw new NotImplemented(); 3447 } 3448 3449 public void setObject(int p1, final java.lang.Object p2) 3450 throws java.sql.SQLException { 3451 delegate.setObject(p1, p2); 3452 } 3453 3454 public void setObject(int p1, final java.lang.Object p2, int p3) 3455 throws java.sql.SQLException { 3456 delegate.setObject(p1, p2, p3); 3457 } 3458 3459 public void setObject(int p1, final java.lang.Object p2, int p3, int p4) 3460 throws java.sql.SQLException { 3461 delegate.setObject(p1, p2, p3, p4); 3462 } 3463 3464 3467 public void setObject(String arg0, Object arg1, int arg2, int arg3) 3468 throws SQLException { 3469 throw new NotImplemented(); 3470 } 3471 3472 3475 public void setObject(String arg0, Object arg1, int arg2) 3476 throws SQLException { 3477 throw new NotImplemented(); 3478 } 3479 3480 3483 public void setObject(String arg0, Object arg1) 3484 throws SQLException { 3485 throw new NotImplemented(); 3486 } 3487 3488 public java.lang.Object getObject(int p1) throws java.sql.SQLException { 3489 throw new SQLException ("Not supported"); 3490 } 3491 3492 public java.lang.Object getObject(int p1, final java.util.Map p2) 3493 throws java.sql.SQLException { 3494 throw new SQLException ("Not supported"); 3495 } 3496 3497 3500 public Object getObject(String arg0, Map arg1) 3501 throws SQLException { 3502 throw new NotImplemented(); 3503 } 3504 3505 3508 public Object getObject(String arg0) throws SQLException { 3509 throw new NotImplemented(); 3510 } 3511 3512 3515 public ParameterMetaData getParameterMetaData() 3516 throws SQLException { 3517 return delegate.getParameterMetaData(); 3518 } 3519 3520 public void setQueryTimeout(int p1) throws java.sql.SQLException { 3521 throw new SQLException ("Not supported"); 3522 } 3523 3524 public int getQueryTimeout() throws java.sql.SQLException { 3525 return delegate.getQueryTimeout(); 3526 } 3527 3528 public void setRef(int p1, final java.sql.Ref p2) 3529 throws java.sql.SQLException { 3530 throw new SQLException ("Not supported"); 3531 } 3532 3533 public java.sql.Ref getRef(int p1) throws java.sql.SQLException { 3534 throw new SQLException ("Not supported"); 3535 } 3536 3537 3540 public Ref getRef(String arg0) throws SQLException { 3541 throw new NotImplemented(); 3542 } 3543 3544 public java.sql.ResultSet getResultSet() throws java.sql.SQLException { 3545 return delegate.getResultSet(); 3546 } 3547 3548 public int getResultSetConcurrency() throws java.sql.SQLException { 3549 return delegate.getResultSetConcurrency(); 3550 } 3551 3552 3555 public int getResultSetHoldability() throws SQLException { 3556 return delegate.getResultSetHoldability(); 3557 } 3558 3559 public int getResultSetType() throws java.sql.SQLException { 3560 return delegate.getResultSetType(); 3561 } 3562 3563 public void setShort(int p1, short p2) throws java.sql.SQLException { 3564 delegate.setShort(p1, p2); 3565 } 3566 3567 3570 public void setShort(String arg0, short arg1) throws SQLException { 3571 throw new NotImplemented(); 3572 } 3573 3574 public short getShort(int p1) throws java.sql.SQLException { 3575 throw new SQLException ("Not supported"); 3576 } 3577 3578 3581 public short getShort(String arg0) throws SQLException { 3582 throw new NotImplemented(); 3583 } 3584 3585 public void setString(int p1, java.lang.String p2) 3586 throws java.sql.SQLException { 3587 delegate.setString(p1, p2); 3588 } 3589 3590 3593 public void setString(String arg0, String arg1) 3594 throws SQLException { 3595 throw new NotImplemented(); 3596 } 3597 3598 public java.lang.String getString(int p1) throws java.sql.SQLException { 3599 throw new SQLException ("Not supported"); 3600 } 3601 3602 3605 public String getString(String arg0) throws SQLException { 3606 throw new NotImplemented(); 3607 } 3608 3609 public void setTime(int p1, final java.sql.Time p2) 3610 throws java.sql.SQLException { 3611 delegate.setTime(p1, p2); 3612 } 3613 3614 public void setTime(int p1, final java.sql.Time p2, 3615 final java.util.Calendar p3) throws java.sql.SQLException { 3616 delegate.setTime(p1, p2, p3); 3617 } 3618 3619 3622 public void setTime(String arg0, Time arg1, Calendar arg2) 3623 throws SQLException { 3624 throw new NotImplemented(); 3625 } 3626 3627 3630 public void setTime(String arg0, Time arg1) throws SQLException { 3631 throw new NotImplemented(); 3632 } 3633 3634 public java.sql.Time getTime(int p1) throws java.sql.SQLException { 3635 throw new SQLException ("Not supported"); 3636 } 3637 3638 public java.sql.Time getTime(int p1, final java.util.Calendar p2) 3639 throws java.sql.SQLException { 3640 throw new SQLException ("Not supported"); 3641 } 3642 3643 3646 public Time getTime(String arg0, Calendar arg1) 3647 throws SQLException { 3648 throw new NotImplemented(); 3649 } 3650 3651 3654 public Time getTime(String arg0) throws SQLException { 3655 throw new NotImplemented(); 3656 } 3657 3658 public void setTimestamp(int p1, final java.sql.Timestamp p2) 3659 throws java.sql.SQLException { 3660 delegate.setTimestamp(p1, p2); 3661 } 3662 3663 public void setTimestamp(int p1, final java.sql.Timestamp p2, 3664 final java.util.Calendar p3) throws java.sql.SQLException { 3665 delegate.setTimestamp(p1, p2, p3); 3666 } 3667 3668 3671 public void setTimestamp(String arg0, Timestamp arg1, Calendar arg2) 3672 throws SQLException { 3673 throw new NotImplemented(); 3674 } 3675 3676 3679 public void setTimestamp(String arg0, Timestamp arg1) 3680 throws SQLException { 3681 throw new NotImplemented(); 3682 } 3683 3684 public java.sql.Timestamp getTimestamp(int p1) 3685 throws java.sql.SQLException { 3686 throw new SQLException ("Not supported"); 3687 } 3688 3689 public java.sql.Timestamp getTimestamp(int p1, 3690 final java.util.Calendar p2) throws java.sql.SQLException { 3691 throw new SQLException ("Not supported"); 3692 } 3693 3694 3697 public Timestamp getTimestamp(String arg0, Calendar arg1) 3698 throws SQLException { 3699 throw new NotImplemented(); 3700 } 3701 3702 3705 public Timestamp getTimestamp(String arg0) throws SQLException { 3706 throw new NotImplemented(); 3707 } 3708 3709 3712 public void setURL(String arg0, URL arg1) throws SQLException { 3713 throw new NotImplemented(); 3714 } 3715 3716 3719 public void setURL(int arg0, URL arg1) throws SQLException { 3720 delegate.setURL(arg0, arg1); 3721 } 3722 3723 3726 public URL getURL(int arg0) throws SQLException { 3727 throw new NotImplemented(); 3728 } 3729 3730 3733 public URL getURL(String arg0) throws SQLException { 3734 throw new NotImplemented(); 3735 } 3736 3737 public void setUnicodeStream(int p1, final java.io.InputStream p2, 3738 int p3) throws java.sql.SQLException { 3739 delegate.setUnicodeStream(p1, p2, p3); 3740 } 3741 3742 public int getUpdateCount() throws java.sql.SQLException { 3743 return delegate.getUpdateCount(); 3744 } 3745 3746 public java.sql.SQLWarning getWarnings() throws java.sql.SQLException { 3747 return delegate.getWarnings(); 3748 } 3749 3750 public void addBatch() throws java.sql.SQLException { 3751 delegate.addBatch(); 3752 } 3753 3754 public void addBatch(java.lang.String p1) throws java.sql.SQLException { 3755 delegate.addBatch(p1); 3756 } 3757 3758 public void cancel() throws java.sql.SQLException { 3759 delegate.cancel(); 3760 } 3761 3762 public void clearBatch() throws java.sql.SQLException { 3763 delegate.clearBatch(); 3764 } 3765 3766 public void clearParameters() throws java.sql.SQLException { 3767 delegate.clearParameters(); 3768 } 3769 3770 public void clearWarnings() throws java.sql.SQLException { 3771 delegate.clearWarnings(); 3772 } 3773 3774 public void close() throws java.sql.SQLException { 3775 delegate.close(); 3776 } 3777 3778 public boolean execute() throws java.sql.SQLException { 3779 return delegate.execute(); 3780 } 3781 3782 public boolean execute(java.lang.String p1) 3783 throws java.sql.SQLException { 3784 return delegate.execute(p1); 3785 } 3786 3787 3790 public boolean execute(String arg0, int arg1) throws SQLException { 3791 return delegate.execute(arg0, arg1); 3792 } 3793 3794 3797 public boolean execute(String arg0, int[] arg1) 3798 throws SQLException { 3799 return delegate.execute(arg0, arg1); 3800 } 3801 3802 3805 public boolean execute(String arg0, String [] arg1) 3806 throws SQLException { 3807 return delegate.execute(arg0, arg1); 3808 } 3809 3810 public int[] executeBatch() throws java.sql.SQLException { 3811 return delegate.executeBatch(); 3812 } 3813 3814 public java.sql.ResultSet executeQuery() throws java.sql.SQLException { 3815 return delegate.executeQuery(); 3816 } 3817 3818 public java.sql.ResultSet executeQuery(java.lang.String p1) 3819 throws java.sql.SQLException { 3820 return delegate.executeQuery(p1); 3821 } 3822 3823 public int executeUpdate() throws java.sql.SQLException { 3824 return delegate.executeUpdate(); 3825 } 3826 3827 public int executeUpdate(java.lang.String p1) 3828 throws java.sql.SQLException { 3829 return delegate.executeUpdate(p1); 3830 } 3831 3832 3835 public int executeUpdate(String arg0, int arg1) 3836 throws SQLException { 3837 return delegate.executeUpdate(arg0, arg1); 3838 } 3839 3840 3843 public int executeUpdate(String arg0, int[] arg1) 3844 throws SQLException { 3845 return delegate.executeUpdate(arg0, arg1); 3846 } 3847 3848 3851 public int executeUpdate(String arg0, String [] arg1) 3852 throws SQLException { 3853 return delegate.executeUpdate(arg0, arg1); 3854 } 3855 3856 public void registerOutParameter(int p1, int p2) 3857 throws java.sql.SQLException { 3858 throw new SQLException ("Not supported"); 3859 } 3860 3861 public void registerOutParameter(int p1, int p2, int p3) 3862 throws java.sql.SQLException { 3863 throw new SQLException ("Not supported"); 3864 } 3865 3866 public void registerOutParameter(int p1, int p2, java.lang.String p3) 3867 throws java.sql.SQLException { 3868 throw new SQLException ("Not supported"); 3869 } 3870 3871 3874 public void registerOutParameter(String arg0, int arg1, int arg2) 3875 throws SQLException { 3876 throw new NotImplemented(); 3877 } 3878 3879 3882 public void registerOutParameter(String arg0, int arg1, String arg2) 3883 throws SQLException { 3884 throw new NotImplemented(); 3885 } 3886 3887 3890 public void registerOutParameter(String arg0, int arg1) 3891 throws SQLException { 3892 throw new NotImplemented(); 3893 } 3894 3895 public boolean wasNull() throws java.sql.SQLException { 3896 throw new SQLException ("Not supported"); 3897 } 3898 } 3899} 3900 | Popular Tags |