1 25 package com.mysql.jdbc; 26 27 import com.mysql.jdbc.log.Jdk14Logger; 28 import com.mysql.jdbc.log.Log; 29 import com.mysql.jdbc.log.Log4JLogger; 30 import com.mysql.jdbc.log.StandardLogger; 31 32 import java.io.UnsupportedEncodingException ; 33 34 import java.sql.DriverPropertyInfo ; 35 import java.sql.SQLException ; 36 37 import java.util.ArrayList ; 38 import java.util.HashMap ; 39 import java.util.Iterator ; 40 import java.util.Map ; 41 import java.util.Properties ; 42 import java.util.TreeMap ; 43 44 import javax.naming.RefAddr ; 45 import javax.naming.Reference ; 46 import javax.naming.StringRefAddr ; 47 48 56 public class ConnectionProperties { 57 class BooleanConnectionProperty extends ConnectionProperty { 58 68 BooleanConnectionProperty(String propertyNameToSet, 69 boolean defaultValueToSet, String descriptionToSet, 70 String sinceVersionToSet, String category, int orderInCategory) { 71 super(propertyNameToSet, new Boolean (defaultValueToSet), null, 0, 72 0, descriptionToSet, sinceVersionToSet, category, 73 orderInCategory); 74 } 75 76 79 String [] getAllowableValues() { 80 return new String [] { "true", "false", "yes", "no" }; 81 } 82 83 boolean getValueAsBoolean() { 84 return ((Boolean ) this.valueAsObject).booleanValue(); 85 } 86 87 90 boolean hasValueConstraints() { 91 return true; 92 } 93 94 97 void initializeFrom(String extractedValue) throws SQLException { 98 if (extractedValue != null) { 99 validateStringValues(extractedValue); 100 101 this.valueAsObject = new Boolean (extractedValue 102 .equalsIgnoreCase("TRUE") 103 || extractedValue.equalsIgnoreCase("YES")); 104 } else { 105 this.valueAsObject = this.defaultValue; 106 } 107 } 108 109 112 boolean isRangeBased() { 113 return false; 114 } 115 116 void setValue(boolean valueFlag) { 117 this.valueAsObject = new Boolean (valueFlag); 118 } 119 } 120 121 abstract class ConnectionProperty extends DriverPropertyInfo { 122 String [] allowableValues; 123 124 String categoryName; 125 126 Object defaultValue; 127 128 int lowerBound; 129 130 int order; 131 132 String propertyName; 133 134 String sinceVersion; 135 136 int upperBound; 137 138 Object valueAsObject; 139 140 ConnectionProperty(String propertyNameToSet, Object defaultValueToSet, 141 String [] allowableValuesToSet, int lowerBoundToSet, 142 int upperBoundToSet, String descriptionToSet, 143 String sinceVersionToSet, String category, int orderInCategory) { 144 super(propertyNameToSet, null); 145 146 this.description = descriptionToSet; 147 this.propertyName = propertyNameToSet; 148 this.defaultValue = defaultValueToSet; 149 this.valueAsObject = defaultValueToSet; 150 this.allowableValues = allowableValuesToSet; 151 this.lowerBound = lowerBoundToSet; 152 this.upperBound = upperBoundToSet; 153 this.required = false; 154 this.sinceVersion = sinceVersionToSet; 155 this.categoryName = category; 156 this.order = orderInCategory; 157 } 158 159 String [] getAllowableValues() { 160 return this.allowableValues; 161 } 162 163 166 String getCategoryName() { 167 return this.categoryName; 168 } 169 170 Object getDefaultValue() { 171 return this.defaultValue; 172 } 173 174 int getLowerBound() { 175 return this.lowerBound; 176 } 177 178 181 int getOrder() { 182 return this.order; 183 } 184 185 String getPropertyName() { 186 return this.propertyName; 187 } 188 189 int getUpperBound() { 190 return this.upperBound; 191 } 192 193 Object getValueAsObject() { 194 return this.valueAsObject; 195 } 196 197 abstract boolean hasValueConstraints(); 198 199 void initializeFrom(Properties extractFrom) throws SQLException { 200 String extractedValue = extractFrom.getProperty(getPropertyName()); 201 extractFrom.remove(getPropertyName()); 202 initializeFrom(extractedValue); 203 } 204 205 void initializeFrom(Reference ref) throws SQLException { 206 RefAddr refAddr = ref.get(getPropertyName()); 207 208 if (refAddr != null) { 209 String refContentAsString = (String ) refAddr.getContent(); 210 211 initializeFrom(refContentAsString); 212 } 213 } 214 215 abstract void initializeFrom(String extractedValue) throws SQLException ; 216 217 abstract boolean isRangeBased(); 218 219 223 void setCategoryName(String categoryName) { 224 this.categoryName = categoryName; 225 } 226 227 231 void setOrder(int order) { 232 this.order = order; 233 } 234 235 void setValueAsObject(Object obj) { 236 this.valueAsObject = obj; 237 } 238 239 void storeTo(Reference ref) { 240 if (getValueAsObject() != null) { 241 ref.add(new StringRefAddr (getPropertyName(), getValueAsObject() 242 .toString())); 243 } 244 } 245 246 250 void syncDriverPropertyInfo() { 251 this.choices = getAllowableValues(); 252 this.value = (this.valueAsObject != null) ? this.valueAsObject 253 .toString() : null; 254 } 255 256 void validateStringValues(String valueToValidate) throws SQLException { 257 String [] validateAgainst = getAllowableValues(); 258 259 if (valueToValidate == null) { 260 return; 261 } 262 263 if ((validateAgainst == null) || (validateAgainst.length == 0)) { 264 return; 265 } 266 267 for (int i = 0; i < validateAgainst.length; i++) { 268 if ((validateAgainst[i] != null) 269 && validateAgainst[i].equalsIgnoreCase(valueToValidate)) { 270 return; 271 } 272 } 273 274 StringBuffer errorMessageBuf = new StringBuffer (); 275 276 errorMessageBuf.append("The connection property '"); 277 errorMessageBuf.append(getPropertyName()); 278 errorMessageBuf.append("' only accepts values of the form: "); 279 280 if (validateAgainst.length != 0) { 281 errorMessageBuf.append("'"); 282 errorMessageBuf.append(validateAgainst[0]); 283 errorMessageBuf.append("'"); 284 285 for (int i = 1; i < (validateAgainst.length - 1); i++) { 286 errorMessageBuf.append(", "); 287 errorMessageBuf.append("'"); 288 errorMessageBuf.append(validateAgainst[i]); 289 errorMessageBuf.append("'"); 290 } 291 292 errorMessageBuf.append(" or '"); 293 errorMessageBuf 294 .append(validateAgainst[validateAgainst.length - 1]); 295 errorMessageBuf.append("'"); 296 } 297 298 errorMessageBuf.append(". The value '"); 299 errorMessageBuf.append(valueToValidate); 300 errorMessageBuf.append("' is not in this set."); 301 302 throw new SQLException (errorMessageBuf.toString(), 303 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 304 } 305 } 306 307 class IntegerConnectionProperty extends ConnectionProperty { 308 int multiplier = 1; 309 310 IntegerConnectionProperty(String propertyNameToSet, 311 int defaultValueToSet, int lowerBoundToSet, 312 int upperBoundToSet, String descriptionToSet, 313 String sinceVersionToSet, String category, int orderInCategory) { 314 super(propertyNameToSet, new Integer (defaultValueToSet), null, 315 lowerBoundToSet, upperBoundToSet, descriptionToSet, 316 sinceVersionToSet, category, orderInCategory); 317 } 318 319 328 329 IntegerConnectionProperty(String propertyNameToSet, 330 int defaultValueToSet, String descriptionToSet, 331 String sinceVersionToSet, String category, int orderInCategory) { 332 this(propertyNameToSet, defaultValueToSet, 0, 0, descriptionToSet, 333 sinceVersionToSet, category, orderInCategory); 334 } 335 336 339 String [] getAllowableValues() { 340 return null; 341 } 342 343 346 int getLowerBound() { 347 return this.lowerBound; 348 } 349 350 353 int getUpperBound() { 354 return this.upperBound; 355 } 356 357 int getValueAsInt() { 358 return ((Integer ) this.valueAsObject).intValue(); 359 } 360 361 364 boolean hasValueConstraints() { 365 return false; 366 } 367 368 371 void initializeFrom(String extractedValue) throws SQLException { 372 if (extractedValue != null) { 373 try { 374 int intValue = Double.valueOf(extractedValue).intValue(); 376 377 386 this.valueAsObject = new Integer (intValue * multiplier); 387 } catch (NumberFormatException nfe) { 388 throw new SQLException ("The connection property '" 389 + getPropertyName() 390 + "' only accepts integer values. The value '" 391 + extractedValue 392 + "' can not be converted to an integer.", 393 SQLError.SQL_STATE_ILLEGAL_ARGUMENT); 394 } 395 } else { 396 this.valueAsObject = this.defaultValue; 397 } 398 } 399 400 403 boolean isRangeBased() { 404 return getUpperBound() != getLowerBound(); 405 } 406 407 void setValue(int valueFlag) { 408 this.valueAsObject = new Integer (valueFlag); 409 } 410 } 411 412 class MemorySizeConnectionProperty extends IntegerConnectionProperty { 413 414 MemorySizeConnectionProperty(String propertyNameToSet, 415 int defaultValueToSet, int lowerBoundToSet, 416 int upperBoundToSet, String descriptionToSet, 417 String sinceVersionToSet, String category, int orderInCategory) { 418 super(propertyNameToSet, defaultValueToSet, lowerBoundToSet, 419 upperBoundToSet, descriptionToSet, sinceVersionToSet, 420 category, orderInCategory); 421 } 423 424 void initializeFrom(String extractedValue) throws SQLException { 425 if (extractedValue != null) { 426 if (extractedValue.endsWith("k") 427 || extractedValue.endsWith("K") 428 || extractedValue.endsWith("kb") 429 || extractedValue.endsWith("Kb") 430 || extractedValue.endsWith("kB")) { 431 multiplier = 1024; 432 int indexOfK = StringUtils.indexOfIgnoreCase( 433 extractedValue, "k"); 434 extractedValue = extractedValue.substring(0, indexOfK); 435 } else if (extractedValue.endsWith("m") 436 || extractedValue.endsWith("M") 437 || extractedValue.endsWith("G") 438 || extractedValue.endsWith("mb") 439 || extractedValue.endsWith("Mb") 440 || extractedValue.endsWith("mB")) { 441 multiplier = 1024 * 1024; 442 int indexOfM = StringUtils.indexOfIgnoreCase( 443 extractedValue, "m"); 444 extractedValue = extractedValue.substring(0, indexOfM); 445 } else if (extractedValue.endsWith("g") 446 || extractedValue.endsWith("G") 447 || extractedValue.endsWith("gb") 448 || extractedValue.endsWith("Gb") 449 || extractedValue.endsWith("gB")) { 450 multiplier = 1024 * 1024 * 1024; 451 int indexOfG = StringUtils.indexOfIgnoreCase( 452 extractedValue, "g"); 453 extractedValue = extractedValue.substring(0, indexOfG); 454 } 455 } 456 457 super.initializeFrom(extractedValue); 458 } 459 460 void setValue(String value) throws SQLException { 461 initializeFrom(value); 462 } 463 } 464 465 class StringConnectionProperty extends ConnectionProperty { 466 StringConnectionProperty(String propertyNameToSet, 467 String defaultValueToSet, String descriptionToSet, 468 String sinceVersionToSet, String category, int orderInCategory) { 469 this(propertyNameToSet, defaultValueToSet, null, descriptionToSet, 470 sinceVersionToSet, category, orderInCategory); 471 } 472 473 483 StringConnectionProperty(String propertyNameToSet, 484 String defaultValueToSet, String [] allowableValuesToSet, 485 String descriptionToSet, String sinceVersionToSet, 486 String category, int orderInCategory) { 487 super(propertyNameToSet, defaultValueToSet, allowableValuesToSet, 488 0, 0, descriptionToSet, sinceVersionToSet, category, 489 orderInCategory); 490 } 491 492 String getValueAsString() { 493 return (String ) this.valueAsObject; 494 } 495 496 499 boolean hasValueConstraints() { 500 return (this.allowableValues != null) 501 && (this.allowableValues.length > 0); 502 } 503 504 507 void initializeFrom(String extractedValue) throws SQLException { 508 if (extractedValue != null) { 509 validateStringValues(extractedValue); 510 511 this.valueAsObject = extractedValue; 512 } else { 513 this.valueAsObject = this.defaultValue; 514 } 515 } 516 517 520 boolean isRangeBased() { 521 return false; 522 } 523 524 void setValue(String valueFlag) { 525 this.valueAsObject = valueFlag; 526 } 527 } 528 529 private static final String CONNECTION_AND_AUTH_CATEGORY = "Connection/Authentication"; 530 531 private static final String DEBUGING_PROFILING_CATEGORY = "Debuging/Profiling"; 532 533 private static final String HA_CATEGORY = "High Availability and Clustering"; 534 535 private static final String MISC_CATEGORY = "Miscellaneous"; 536 537 private static final String PERFORMANCE_CATEGORY = "Performance Extensions"; 538 539 private static final ArrayList PROPERTY_LIST = new ArrayList (); 540 541 private static final String SECURITY_CATEGORY = "Security"; 542 543 private static final String [] PROPERTY_CATEGORIES = new String [] { 544 CONNECTION_AND_AUTH_CATEGORY, HA_CATEGORY, SECURITY_CATEGORY, 545 PERFORMANCE_CATEGORY, DEBUGING_PROFILING_CATEGORY, MISC_CATEGORY }; 546 547 private static final String STANDARD_LOGGER_NAME = StandardLogger.class 548 .getName(); 549 550 protected static final String ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL = "convertToNull"; 551 552 protected static final String ZERO_DATETIME_BEHAVIOR_EXCEPTION = "exception"; 553 554 protected static final String ZERO_DATETIME_BEHAVIOR_ROUND = "round"; 555 556 static { 557 try { 558 java.lang.reflect.Field [] declaredFields = ConnectionProperties.class 559 .getDeclaredFields(); 560 561 for (int i = 0; i < declaredFields.length; i++) { 562 if (ConnectionProperties.ConnectionProperty.class 563 .isAssignableFrom(declaredFields[i].getType())) { 564 PROPERTY_LIST.add(declaredFields[i]); 565 } 566 } 567 } catch (Exception ex) { 568 throw new RuntimeException (ex.toString()); 569 } 570 } 571 572 586 protected static DriverPropertyInfo [] exposeAsDriverPropertyInfo( 587 Properties info, int slotsToReserve) throws SQLException { 588 return (new ConnectionProperties() { 589 }).exposeAsDriverPropertyInfoInternal(info, slotsToReserve); 590 } 591 592 private BooleanConnectionProperty allowLoadLocalInfile = new BooleanConnectionProperty( 593 "allowLoadLocalInfile", 594 true, 595 "Should the driver allow use of 'LOAD DATA LOCAL INFILE...' (defaults to 'true').", 596 "3.0.3", SECURITY_CATEGORY, Integer.MAX_VALUE); 597 598 private BooleanConnectionProperty allowMultiQueries = new BooleanConnectionProperty( 599 "allowMultiQueries", 600 false, 601 "Allow the use of ';' to delimit multiple queries during one statement (true/false, defaults to 'false'", 602 "3.1.1", SECURITY_CATEGORY, 1); 603 604 private BooleanConnectionProperty allowNanAndInf = new BooleanConnectionProperty( 605 "allowNanAndInf", 606 false, 607 "Should the driver allow NaN or +/- INF values in PreparedStatement.setDouble()?", 608 "3.1.5", MISC_CATEGORY, Integer.MIN_VALUE); 609 610 private BooleanConnectionProperty allowUrlInLocalInfile = new BooleanConnectionProperty( 611 "allowUrlInLocalInfile", 612 false, 613 "Should the driver allow URLs in 'LOAD DATA LOCAL INFILE' statements?", 614 "3.1.4", SECURITY_CATEGORY, Integer.MAX_VALUE); 615 616 private BooleanConnectionProperty alwaysSendSetIsolation = new BooleanConnectionProperty( 617 "alwaysSendSetIsolation", 618 true, 619 "Should the driver always communicate with the database when " 620 + " Connection.setTransactionIsolation() is called? " 621 + "If set to false, the driver will only communicate with the " 622 + "database when the requested transaction isolation is different " 623 + "than the whichever is newer, the last value that was set via " 624 + "Connection.setTransactionIsolation(), or the value that was read from " 625 + "the server when the connection was established.", 626 "3.1.7", PERFORMANCE_CATEGORY, Integer.MAX_VALUE); 627 628 private BooleanConnectionProperty autoDeserialize = new BooleanConnectionProperty( 629 "autoDeserialize", 630 false, 631 "Should the driver automatically detect and de-serialize objects stored in BLOB fields?", 632 "3.1.5", MISC_CATEGORY, Integer.MIN_VALUE); 633 634 private BooleanConnectionProperty autoGenerateTestcaseScript = new BooleanConnectionProperty( 635 "autoGenerateTestcaseScript", false, 636 "Should the driver dump the SQL it is executing, including server-side " 637 + "prepared statements to STDERR?", "3.1.9", 638 DEBUGING_PROFILING_CATEGORY, Integer.MIN_VALUE); 639 640 private boolean autoGenerateTestcaseScriptAsBoolean = false; 641 642 private BooleanConnectionProperty autoReconnect = new BooleanConnectionProperty( 643 "autoReconnect", false, 644 "Should the driver try to re-establish bad connections?", "1.1", 645 HA_CATEGORY, 0); 646 647 private BooleanConnectionProperty autoReconnectForPools = new BooleanConnectionProperty( 648 "autoReconnectForPools", 649 false, 650 "Use a reconnection strategy appropriate for connection pools (defaults to 'false')", 651 "3.1.3", HA_CATEGORY, 1); 652 653 private boolean autoReconnectForPoolsAsBoolean = false; 654 655 private MemorySizeConnectionProperty blobSendChunkSize = new MemorySizeConnectionProperty( 656 "blobSendChunkSize", 657 1024 * 1024, 658 1, 659 Integer.MAX_VALUE, 660 "Chunk to use when sending BLOB/CLOBs via ServerPreparedStatements", 661 "3.1.9", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 662 663 private BooleanConnectionProperty cacheCallableStatements = new BooleanConnectionProperty( 664 "cacheCallableStmts", false, 665 "Should the driver cache the parsing stage of CallableStatements", 666 "3.1.2", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 667 668 private BooleanConnectionProperty cachePreparedStatements = new BooleanConnectionProperty( 669 "cachePrepStmts", 670 false, 671 "Should the driver cache the parsing stage of PreparedStatements of client-side " 672 + "prepared statements, the \"check\" for suitability of server-side prepared " 673 + " and server-side prepared statements themselves?", 674 "3.0.10", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 675 676 private BooleanConnectionProperty cacheResultSetMetadata = new BooleanConnectionProperty( 677 "cacheResultSetMetadata", 678 false, 679 "Should the driver cache ResultSetMetaData for Statements and PreparedStatements? (Req. JDK-1.4+, true/false, default 'false')", 680 "3.1.1", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 681 682 private boolean cacheResultSetMetaDataAsBoolean; 683 684 private BooleanConnectionProperty cacheServerConfiguration = new BooleanConnectionProperty( 685 "cacheServerConfiguration", 686 false, 687 "Should the driver cache the results of " 688 + "'SHOW VARIABLES' and 'SHOW COLLATION' on a per-URL basis?", 689 "3.1.5", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 690 691 private IntegerConnectionProperty callableStatementCacheSize = new IntegerConnectionProperty( 692 "callableStmtCacheSize", 693 100, 694 0, 695 Integer.MAX_VALUE, 696 "If 'cacheCallableStmts' is enabled, how many callable statements should be cached?", 697 "3.1.2", PERFORMANCE_CATEGORY, 5); 698 699 private BooleanConnectionProperty capitalizeTypeNames = new BooleanConnectionProperty( 700 "capitalizeTypeNames", 701 false, 702 "Capitalize type names in DatabaseMetaData? (usually only useful when using WebObjects, true/false, defaults to 'false')", 703 "2.0.7", MISC_CATEGORY, Integer.MIN_VALUE); 704 705 private StringConnectionProperty characterEncoding = new StringConnectionProperty( 706 "characterEncoding", 707 null, 708 "If 'useUnicode' is set to true, what character encoding should the driver use when dealing with strings? (defaults is to 'autodetect')", 709 "1.1g", MISC_CATEGORY, 5); 710 711 private String characterEncodingAsString = null; 712 713 private StringConnectionProperty characterSetResults = new StringConnectionProperty( 714 "characterSetResults", null, 715 "Character set to tell the server to return results as.", "3.0.13", 716 MISC_CATEGORY, 6); 717 718 private BooleanConnectionProperty clobberStreamingResults = new BooleanConnectionProperty( 719 "clobberStreamingResults", 720 false, 721 "This will cause a 'streaming' ResultSet to be automatically closed, " 722 + "and any outstanding data still streaming from the server to be discarded if another query is executed " 723 + "before all the data has been read from the server.", 724 "3.0.9", MISC_CATEGORY, Integer.MIN_VALUE); 725 726 private StringConnectionProperty connectionCollation = new StringConnectionProperty( 727 "connectionCollation", 728 null, 729 "If set, tells the server to use this collation via 'set connection_collation'", 730 "3.0.13", MISC_CATEGORY, 7); 731 732 private IntegerConnectionProperty connectTimeout = new IntegerConnectionProperty( 733 "connectTimeout", 0, 0, Integer.MAX_VALUE, 734 "Timeout for socket connect (in milliseconds), with 0 being no timeout. " 735 + "Only works on JDK-1.4 or newer. Defaults to '0'.", 736 "3.0.1", CONNECTION_AND_AUTH_CATEGORY, 9); 737 738 private BooleanConnectionProperty continueBatchOnError = new BooleanConnectionProperty( 739 "continueBatchOnError", 740 true, 741 "Should the driver continue processing batch commands if " 742 + "one statement fails. The JDBC spec allows either way (defaults to 'true').", 743 "3.0.3", MISC_CATEGORY, Integer.MIN_VALUE); 744 745 private BooleanConnectionProperty createDatabaseIfNotExist = new BooleanConnectionProperty( 746 "createDatabaseIfNotExist", 747 false, 748 "Creates the database given in the URL if it doesn't yet exist. Assumes " 749 + " the configured user has permissions to create databases.", 750 "3.1.9", MISC_CATEGORY, Integer.MIN_VALUE); 751 752 private BooleanConnectionProperty detectServerPreparedStmts = new BooleanConnectionProperty( 753 "useServerPrepStmts", 754 true, 755 "Use server-side prepared statements if the server supports them? (defaults to 'true').", 756 "3.1.0", MISC_CATEGORY, Integer.MIN_VALUE); 757 758 private BooleanConnectionProperty dontTrackOpenResources = new BooleanConnectionProperty( 759 "dontTrackOpenResources", 760 false, 761 "The JDBC specification requires the driver to automatically track and close resources, " 762 + "however if your application doesn't do a good job of " 763 + "explicitly calling close() on statements or result sets, " 764 + "this can cause memory leakage. Setting this property to true " 765 + "relaxes this constraint, and can be more memory efficient for " 766 + "some applications.", "3.1.7", PERFORMANCE_CATEGORY, 767 Integer.MIN_VALUE); 768 769 private BooleanConnectionProperty dumpQueriesOnException = new BooleanConnectionProperty( 770 "dumpQueriesOnException", 771 false, 772 "Should the driver dump the contents of the query sent to the server in the message for SQLExceptions?", 773 "3.1.3", DEBUGING_PROFILING_CATEGORY, Integer.MIN_VALUE); 774 775 private BooleanConnectionProperty dynamicCalendars = new BooleanConnectionProperty( 776 "dynamicCalendars", 777 false, 778 "Should the driver retrieve the default" 779 + " calendar when required, or cache it per connection/session?", 780 "3.1.5", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 781 782 private BooleanConnectionProperty elideSetAutoCommits = new BooleanConnectionProperty( 783 "elideSetAutoCommits", 784 false, 785 "If using MySQL-4.1 or newer, should the driver only issue 'set autocommit=n' queries when the server's state doesn't match the requested state by Connection.setAutoCommit(boolean)?", 786 "3.1.3", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 787 788 private BooleanConnectionProperty emptyStringsConvertToZero = new BooleanConnectionProperty( 789 "emptyStringsConvertToZero", true, 790 "Should the driver allow conversions from empty string " 791 + "fields to numeric values of '0'?", "3.1.8", 792 MISC_CATEGORY, Integer.MIN_VALUE); 793 794 private BooleanConnectionProperty emulateLocators = new BooleanConnectionProperty( 795 "emulateLocators", false, "N/A", "3.1.0", MISC_CATEGORY, 796 Integer.MIN_VALUE); 797 798 private BooleanConnectionProperty emulateUnsupportedPstmts = new BooleanConnectionProperty( 799 "emulateUnsupportedPstmts", 800 true, 801 "Should the driver detect prepared statements that are not supported by the server, and " 802 + "replace them with client-side emulated versions?", 803 "3.1.7", MISC_CATEGORY, Integer.MIN_VALUE); 804 805 private BooleanConnectionProperty enableDeprecatedAutoreconnect = new BooleanConnectionProperty( 806 "enableDeprecatedAutoreconnect", 807 false, 808 "Auto-reconnect functionality is deprecated starting with version 3.2, and will be removed in version 3.3. Set this " 809 + "property to 'true' to disable the check for the feature being configured.", 810 "3.2.1", HA_CATEGORY, Integer.MIN_VALUE); 811 812 private BooleanConnectionProperty enablePacketDebug = new BooleanConnectionProperty( 813 "enablePacketDebug", 814 false, 815 "When enabled, a ring-buffer of 'packetDebugBufferSize' packets will be kept, and dumped when exceptions are thrown in key areas in the driver's code", 816 "3.1.3", DEBUGING_PROFILING_CATEGORY, Integer.MIN_VALUE); 817 818 private BooleanConnectionProperty explainSlowQueries = new BooleanConnectionProperty( 819 "explainSlowQueries", 820 false, 821 "If 'logSlowQueries' is enabled, should the driver automatically issue an 'EXPLAIN' on the" 822 + " server and send the results to the configured log at a WARN level?", 823 "3.1.2", DEBUGING_PROFILING_CATEGORY, Integer.MIN_VALUE); 824 825 826 private BooleanConnectionProperty failOverReadOnly = new BooleanConnectionProperty( 827 "failOverReadOnly", 828 true, 829 "When failing over in autoReconnect mode, should the connection be set to 'read-only'?", 830 "3.0.12", HA_CATEGORY, 2); 831 832 private BooleanConnectionProperty gatherPerformanceMetrics = new BooleanConnectionProperty( 833 "gatherPerfMetrics", 834 false, 835 "Should the driver gather performance metrics, and report them via the configured logger every 'reportMetricsIntervalMillis' milliseconds?", 836 "3.1.2", DEBUGING_PROFILING_CATEGORY, 1); 837 838 private boolean highAvailabilityAsBoolean = false; 839 840 private BooleanConnectionProperty holdResultsOpenOverStatementClose = new BooleanConnectionProperty( 841 "holdResultsOpenOverStatementClose", 842 false, 843 "Should the driver close result sets on Statement.close() as required by the JDBC specification?", 844 "3.1.7", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 845 846 private BooleanConnectionProperty ignoreNonTxTables = new BooleanConnectionProperty( 847 "ignoreNonTxTables", 848 false, 849 "Ignore non-transactional table warning for rollback? (defaults to 'false').", 850 "3.0.9", MISC_CATEGORY, Integer.MIN_VALUE); 851 852 private IntegerConnectionProperty initialTimeout = new IntegerConnectionProperty( 853 "initialTimeout", 2, 1, Integer.MAX_VALUE, 854 "If autoReconnect is enabled, the" 855 + " initial time to wait between" 856 + " re-connect attempts (in seconds, defaults to '2').", 857 "1.1", HA_CATEGORY, 5); 858 859 private BooleanConnectionProperty isInteractiveClient = new BooleanConnectionProperty( 860 "interactiveClient", 861 false, 862 "Set the CLIENT_INTERACTIVE flag, which tells MySQL " 863 + "to timeout connections based on INTERACTIVE_TIMEOUT instead of WAIT_TIMEOUT", 864 "3.1.0", CONNECTION_AND_AUTH_CATEGORY, Integer.MIN_VALUE); 865 866 private BooleanConnectionProperty jdbcCompliantTruncation = new BooleanConnectionProperty( 867 "jdbcCompliantTruncation", 868 true, 869 "Should the driver throw java.sql.DataTruncation" 870 + " exceptions when data is truncated as is required by the JDBC specification when connected to a server that supports warnings" 871 + "(MySQL 4.1.0 and newer)?", "3.1.2", MISC_CATEGORY, 872 Integer.MIN_VALUE); 873 874 private MemorySizeConnectionProperty locatorFetchBufferSize = new MemorySizeConnectionProperty( 875 "locatorFetchBufferSize", 876 1024 * 1024, 877 0, 878 Integer.MAX_VALUE, 879 "If 'emulateLocators' is configured to 'true', what size " 880 + " buffer should be used when fetching BLOB data for getBinaryInputStream?", 881 "3.2.1", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 882 883 private StringConnectionProperty loggerClassName = new StringConnectionProperty( 884 "logger", STANDARD_LOGGER_NAME, 885 "The name of a class that implements '" + Log.class.getName() 886 + "' that will be used to log messages to." 887 + "(default is '" + STANDARD_LOGGER_NAME + "', which " 888 + "logs to STDERR)", "3.1.1", DEBUGING_PROFILING_CATEGORY, 889 0); 890 891 private BooleanConnectionProperty logSlowQueries = new BooleanConnectionProperty( 892 "logSlowQueries", 893 false, 894 "Should queries that take longer than 'slowQueryThresholdMillis' be logged?", 895 "3.1.2", DEBUGING_PROFILING_CATEGORY, Integer.MIN_VALUE); 896 897 private BooleanConnectionProperty maintainTimeStats = new BooleanConnectionProperty( 898 "maintainTimeStats", 899 true, 900 "Should the driver maintain various internal timers to enable " 901 + "idle time calculations as well as more verbose error messages when " 902 + "the connection to the server fails? Setting this property to " 903 + "false removes at least two calls to System.getCurrentTimeMillis() " 904 + "per query.", "3.1.9", PERFORMANCE_CATEGORY, 905 Integer.MAX_VALUE); 906 907 private boolean maintainTimeStatsAsBoolean = true; 908 909 private IntegerConnectionProperty maxQuerySizeToLog = new IntegerConnectionProperty( 910 "maxQuerySizeToLog", 911 2048, 912 0, 913 Integer.MAX_VALUE, 914 "Controls the maximum length/size of a query that will get logged when profiling or tracing", 915 "3.1.3", DEBUGING_PROFILING_CATEGORY, 4); 916 917 private IntegerConnectionProperty maxReconnects = new IntegerConnectionProperty( 918 "maxReconnects", 919 3, 920 1, 921 Integer.MAX_VALUE, 922 "Maximum number of reconnects to attempt if autoReconnect is true, default is '3'.", 923 "1.1", HA_CATEGORY, 4); 924 925 private IntegerConnectionProperty maxRows = new IntegerConnectionProperty( 926 "maxRows", -1, -1, Integer.MAX_VALUE, 927 "The maximum number of rows to return " 928 + " (0, the default means return all rows).", 929 "all versions", MISC_CATEGORY, Integer.MIN_VALUE); 930 931 private int maxRowsAsInt = -1; 932 933 private IntegerConnectionProperty metadataCacheSize = new IntegerConnectionProperty( 934 "metadataCacheSize", 935 50, 936 1, 937 Integer.MAX_VALUE, 938 "The number of queries to cache" 939 + "ResultSetMetadata for if cacheResultSetMetaData is set to 'true' (default 50)", 940 "3.1.1", PERFORMANCE_CATEGORY, 5); 941 942 private BooleanConnectionProperty noDatetimeStringSync = new BooleanConnectionProperty( 943 "noDatetimeStringSync", 944 false, 945 "Don't ensure that ResultSet.getDatetimeType().toString().equals(ResultSet.getString())", 946 "3.1.7", MISC_CATEGORY, Integer.MIN_VALUE); 947 948 private BooleanConnectionProperty nullCatalogMeansCurrent = new BooleanConnectionProperty( 949 "nullCatalogMeansCurrent", 950 true, 951 "When DatabaseMetadataMethods ask for a 'catalog' parameter, does the value null mean use the current catalog? " 952 + "(this is not JDBC-compliant, but follows legacy behavior from earlier versions of the driver)", 953 "3.1.8", MISC_CATEGORY, Integer.MIN_VALUE); 954 955 private BooleanConnectionProperty nullNamePatternMatchesAll = new BooleanConnectionProperty( 956 "nullNamePatternMatchesAll", 957 true, 958 "Should DatabaseMetaData methods that accept *pattern parameters treat null the same as '%' " 959 + " (this is not JDBC-compliant, however older versions of the driver accepted this departure from the specification)", 960 "3.1.8", MISC_CATEGORY, Integer.MIN_VALUE); 961 962 private IntegerConnectionProperty packetDebugBufferSize = new IntegerConnectionProperty( 963 "packetDebugBufferSize", 964 20, 965 0, 966 Integer.MAX_VALUE, 967 "The maximum number of packets to retain when 'enablePacketDebug' is true", 968 "3.1.3", DEBUGING_PROFILING_CATEGORY, 7); 969 970 private BooleanConnectionProperty paranoid = new BooleanConnectionProperty( 971 "paranoid", 972 false, 973 "Take measures to prevent exposure sensitive information in error messages and clear " 974 + "data structures holding sensitive data when possible? (defaults to 'false')", 975 "3.0.1", SECURITY_CATEGORY, Integer.MIN_VALUE); 976 977 private BooleanConnectionProperty pedantic = new BooleanConnectionProperty( 978 "pedantic", false, "Follow the JDBC spec to the letter.", "3.0.0", 979 MISC_CATEGORY, Integer.MIN_VALUE); 980 981 private IntegerConnectionProperty preparedStatementCacheSize = new IntegerConnectionProperty( 982 "prepStmtCacheSize", 25, 0, Integer.MAX_VALUE, 983 "If prepared statement caching is enabled, " 984 + "how many prepared statements should be cached?", 985 "3.0.10", PERFORMANCE_CATEGORY, 10); 986 987 private IntegerConnectionProperty preparedStatementCacheSqlLimit = new IntegerConnectionProperty( 988 "prepStmtCacheSqlLimit", 989 256, 990 1, 991 Integer.MAX_VALUE, 992 "If prepared statement caching is enabled, " 993 + "what's the largest SQL the driver will cache the parsing for?", 994 "3.0.10", PERFORMANCE_CATEGORY, 11); 995 996 private StringConnectionProperty profileSql = new StringConnectionProperty( 997 "profileSql", 998 null, 999 "Deprecated, use 'profileSQL' instead. Trace queries and their execution/fetch times on STDERR (true/false) defaults to 'false'", 1000 "2.0.14", DEBUGING_PROFILING_CATEGORY, 3); 1001 1002 private BooleanConnectionProperty profileSQL = new BooleanConnectionProperty( 1003 "profileSQL", 1004 false, 1005 "Trace queries and their execution/fetch times to the configured logger (true/false) defaults to 'false'", 1006 "3.1.0", DEBUGING_PROFILING_CATEGORY, 1); 1007 1008 private boolean profileSQLAsBoolean = false; 1009 1010 private StringConnectionProperty propertiesTransform = new StringConnectionProperty( 1011 NonRegisteringDriver.PROPERTIES_TRANSFORM_KEY, 1012 null, 1013 "An implementation of com.mysql.jdbc.ConnectionPropertiesTransform that the driver will use to modify URL properties passed to the driver before attempting a connection", 1014 "3.1.4", CONNECTION_AND_AUTH_CATEGORY, Integer.MIN_VALUE); 1015 1016 private IntegerConnectionProperty queriesBeforeRetryMaster = new IntegerConnectionProperty( 1017 "queriesBeforeRetryMaster", 1018 50, 1019 1, 1020 Integer.MAX_VALUE, 1021 "Number of queries to issue before falling back to master when failed over " 1022 + "(when using multi-host failover). Whichever condition is met first, " 1023 + "'queriesBeforeRetryMaster' or 'secondsBeforeRetryMaster' will cause an " 1024 + "attempt to be made to reconnect to the master. Defaults to 50.", 1025 "3.0.2", HA_CATEGORY, 7); 1026 1027 private BooleanConnectionProperty reconnectAtTxEnd = new BooleanConnectionProperty( 1028 "reconnectAtTxEnd", false, 1029 "If autoReconnect is set to true, should the driver attempt reconnections" 1030 + "at the end of every transaction?", "3.0.10", 1031 HA_CATEGORY, 4); 1032 1033 private boolean reconnectTxAtEndAsBoolean = false; 1034 1035 private BooleanConnectionProperty relaxAutoCommit = new BooleanConnectionProperty( 1036 "relaxAutoCommit", 1037 false, 1038 "If the version of MySQL the driver connects to does not support transactions, still allow calls to commit(), rollback() and setAutoCommit() (true/false, defaults to 'false')?", 1039 "2.0.13", MISC_CATEGORY, Integer.MIN_VALUE); 1040 1041 private IntegerConnectionProperty reportMetricsIntervalMillis = new IntegerConnectionProperty( 1042 "reportMetricsIntervalMillis", 1043 30000, 1044 0, 1045 Integer.MAX_VALUE, 1046 "If 'gatherPerfMetrics' is enabled, how often should they be logged (in ms)?", 1047 "3.1.2", DEBUGING_PROFILING_CATEGORY, 3); 1048 1049 private BooleanConnectionProperty requireSSL = new BooleanConnectionProperty( 1050 "requireSSL", false, 1051 "Require SSL connection if useSSL=true? (defaults to 'false').", 1052 "3.1.0", SECURITY_CATEGORY, 3); 1053 1054 private BooleanConnectionProperty rollbackOnPooledClose = new BooleanConnectionProperty( 1055 "rollbackOnPooledClose", 1056 true, 1057 "Should the driver issue a rollback() when the logical connection in a pool is closed?", 1058 "3.0.15", MISC_CATEGORY, Integer.MIN_VALUE); 1059 1060 private BooleanConnectionProperty roundRobinLoadBalance = new BooleanConnectionProperty( 1061 "roundRobinLoadBalance", 1062 false, 1063 "When autoReconnect is enabled, and failoverReadonly is false, should we pick hosts to connect to on a round-robin basis?", 1064 "3.1.2", HA_CATEGORY, 5); 1065 1066 private BooleanConnectionProperty runningCTS13 = new BooleanConnectionProperty( 1067 "runningCTS13", 1068 false, 1069 "Enables workarounds for bugs in Sun's JDBC compliance testsuite version 1.3", 1070 "3.1.7", MISC_CATEGORY, Integer.MIN_VALUE); 1071 1072 private IntegerConnectionProperty secondsBeforeRetryMaster = new IntegerConnectionProperty( 1073 "secondsBeforeRetryMaster", 1074 30, 1075 1, 1076 Integer.MAX_VALUE, 1077 "How long should the driver wait, when failed over, before attempting " 1078 + "to reconnect to the master server? Whichever condition is met first, " 1079 + "'queriesBeforeRetryMaster' or 'secondsBeforeRetryMaster' will cause an " 1080 + "attempt to be made to reconnect to the master. Time in seconds, defaults to 30", 1081 "3.0.2", HA_CATEGORY, 8); 1082 1083 private StringConnectionProperty serverTimezone = new StringConnectionProperty( 1084 "serverTimezone", 1085 null, 1086 "Override detection/mapping of timezone. Used when timezone from server doesn't map to Java timezone", 1087 "3.0.2", MISC_CATEGORY, Integer.MIN_VALUE); 1088 1089 private StringConnectionProperty sessionVariables = new StringConnectionProperty( 1090 "sessionVariables", null, 1091 "A comma-separated list of name/value pairs to be sent as SET SESSION ... to " 1092 + " the server when the driver connects.", "3.1.8", 1093 MISC_CATEGORY, Integer.MAX_VALUE); 1094 1095 private IntegerConnectionProperty slowQueryThresholdMillis = new IntegerConnectionProperty( 1096 "slowQueryThresholdMillis", 1097 2000, 1098 0, 1099 Integer.MAX_VALUE, 1100 "If 'logSlowQueries' is enabled, how long should a query (in ms) before it is logged as 'slow'?", 1101 "3.1.2", DEBUGING_PROFILING_CATEGORY, 9); 1102 1103 private StringConnectionProperty socketFactoryClassName = new StringConnectionProperty( 1104 "socketFactory", 1105 StandardSocketFactory.class.getName(), 1106 "The name of the class that the driver should use for creating socket connections to the server. This class must implement the interface 'com.mysql.jdbc.SocketFactory' and have public no-args constructor.", 1107 "3.0.3", CONNECTION_AND_AUTH_CATEGORY, 4); 1108 1109 private IntegerConnectionProperty socketTimeout = new IntegerConnectionProperty( 1110 "socketTimeout", 1111 0, 1112 0, 1113 Integer.MAX_VALUE, 1114 "Timeout on network socket operations (0, the default means no timeout).", 1115 "3.0.1", CONNECTION_AND_AUTH_CATEGORY, 10); 1116 1117 private BooleanConnectionProperty strictFloatingPoint = new BooleanConnectionProperty( 1118 "strictFloatingPoint", false, 1119 "Used only in older versions of compliance test", "3.0.0", 1120 MISC_CATEGORY, Integer.MIN_VALUE); 1121 1122 private BooleanConnectionProperty strictUpdates = new BooleanConnectionProperty( 1123 "strictUpdates", 1124 true, 1125 "Should the driver do strict checking (all primary keys selected) of updatable result sets (true, false, defaults to 'true')?", 1126 "3.0.4", MISC_CATEGORY, Integer.MIN_VALUE); 1127 1128 private BooleanConnectionProperty tinyInt1isBit = new BooleanConnectionProperty( 1129 "tinyInt1isBit", 1130 true, 1131 "Should the driver treat the datatype TINYINT(1) as the BIT type " 1132 + "(because the server silently converts BIT -> TINYINT(1) when creating tables)?", 1133 "3.0.16", MISC_CATEGORY, Integer.MIN_VALUE); 1134 1135 private BooleanConnectionProperty traceProtocol = new BooleanConnectionProperty( 1136 "traceProtocol", false, 1137 "Should trace-level network protocol be logged?", "3.1.2", 1138 DEBUGING_PROFILING_CATEGORY, Integer.MIN_VALUE); 1139 1140 private BooleanConnectionProperty transformedBitIsBoolean = new BooleanConnectionProperty( 1141 "transformedBitIsBoolean", 1142 false, 1143 "If the driver converts TINYINT(1) to a different type, should it use BOOLEAN instead of BIT " 1144 + " for future compatibility with MySQL-5.0, as MySQL-5.0 has a BIT type?", 1145 "3.1.9", MISC_CATEGORY, Integer.MIN_VALUE); 1146 1147 private BooleanConnectionProperty useCompression = new BooleanConnectionProperty( 1148 "useCompression", 1149 false, 1150 "Use zlib compression when communicating with the server (true/false)? Defaults to 'false'.", 1151 "3.0.17", CONNECTION_AND_AUTH_CATEGORY, Integer.MIN_VALUE); 1152 1153 private StringConnectionProperty useConfig = new StringConnectionProperty( 1154 "useConfigs", 1155 null, 1156 "Load the comma-delimited list of configuration properties before parsing the " 1157 + "URL or applying user-specified properties. These configurations are explained in the 'Configurations' of the documentation.", 1158 "3.1.5", CONNECTION_AND_AUTH_CATEGORY, Integer.MAX_VALUE); 1159 1160 private BooleanConnectionProperty useFastIntParsing = new BooleanConnectionProperty( 1161 "useFastIntParsing", 1162 true, 1163 "Use internal String->Integer conversion routines to avoid excessive object creation?", 1164 "3.1.4", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 1165 1166 private BooleanConnectionProperty useHostsInPrivileges = new BooleanConnectionProperty( 1167 "useHostsInPrivileges", 1168 true, 1169 "Add '@hostname' to users in DatabaseMetaData.getColumn/TablePrivileges() (true/false), defaults to 'true'.", 1170 "3.0.2", MISC_CATEGORY, Integer.MIN_VALUE); 1171 1172 private BooleanConnectionProperty useLocalSessionState = new BooleanConnectionProperty( 1173 "useLocalSessionState", 1174 false, 1175 "Should the driver refer to the internal values of autocommit and transaction isolation that are set " 1176 + " by Connection.setAutoCommit() and Connection.setTransactionIsolation(), rather than querying the database?", 1177 "3.1.7", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 1178 1179 private BooleanConnectionProperty useNewIo = new BooleanConnectionProperty( 1180 "useNewIO", 1181 false, 1182 "Should the driver use the java.nio.* interfaces for network communication (true/false), defaults to 'false'", 1183 "3.1.0", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 1184 1185 private BooleanConnectionProperty useOldUTF8Behavior = new BooleanConnectionProperty( 1186 "useOldUTF8Behavior", 1187 false, 1188 "Use the UTF-8 behavior the driver did when communicating with 4.0 and older servers", 1189 "3.1.6", MISC_CATEGORY, Integer.MIN_VALUE); 1190 1191 private boolean useOldUTF8BehaviorAsBoolean = false; 1192 1193 private BooleanConnectionProperty useOnlyServerErrorMessages = new BooleanConnectionProperty( 1194 "useOnlyServerErrorMessages", 1195 true, 1196 "Don't prepend 'standard' SQLState error messages to error messages returned by the server.", 1197 "3.0.15", MISC_CATEGORY, Integer.MIN_VALUE); 1198 1199 private BooleanConnectionProperty useReadAheadInput = new BooleanConnectionProperty( 1200 "useReadAheadInput", 1201 true, 1202 "Use newer, optimized non-blocking, buffered input stream when reading from the server?", 1203 "3.1.5", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); 1204 1205 private BooleanConnectionProperty useSqlStateCodes = new BooleanConnectionProperty( 1206 "useSqlStateCodes", 1207 true, 1208 "Use SQL Standard state codes instead of 'legacy' X/Open/SQL state codes (true/false), default is 'true'", 1209 "3.1.3", MISC_CATEGORY, Integer.MIN_VALUE); 1210 1211 private BooleanConnectionProperty useSSL = new BooleanConnectionProperty( 1212 "useSSL", 1213 false, 1214 "Use SSL when communicating with the server (true/false), defaults to 'false'", 1215 "3.0.2", SECURITY_CATEGORY, 2); 1216 1217 private BooleanConnectionProperty useStreamLengthsInPrepStmts = new BooleanConnectionProperty( 1218 "useStreamLengthsInPrepStmts", 1219 true, 1220 "Honor stream length parameter in " 1221 + "PreparedStatement/ResultSet.setXXXStream() method calls (true/false, defaults to 'true')?", 1222 "3.0.2", MISC_CATEGORY, Integer.MIN_VALUE); 1223 1224 private BooleanConnectionProperty useTimezone = new BooleanConnectionProperty( 1225 "useTimezone", 1226 false, 1227 "Convert time/date types between client and server timezones (true/false, defaults to 'false')?", 1228 "3.0.2", MISC_CATEGORY, Integer.MIN_VALUE); 1229 1230 private BooleanConnectionProperty useUltraDevWorkAround = new BooleanConnectionProperty( 1231 "ultraDevHack", 1232 false, 1233 "Create PreparedStatements for prepareCall() when required, because UltraDev " 1234 + " is broken and issues a prepareCall() for _all_ statements? (true/false, defaults to 'false')", 1235 "2.0.3", MISC_CATEGORY, Integer.MIN_VALUE); 1236 1237 private BooleanConnectionProperty useUnbufferedInput = new BooleanConnectionProperty( 1238 "useUnbufferedInput", true, 1239 "Don't use BufferedInputStream for reading data from the server", 1240 "3.0.11", MISC_CATEGORY, Integer.MIN_VALUE); 1241 1242 private BooleanConnectionProperty useUnicode = new BooleanConnectionProperty( 1243 "useUnicode", 1244 false, 1245 "Should the driver use Unicode character encodings when handling strings? Should only be used when the driver can't determine the character set mapping, or you are trying to 'force' the driver to use a character set that MySQL either doesn't natively support (such as UTF-8), true/false, defaults to 'true'", 1246 "1.1g", MISC_CATEGORY, 0); 1247 1248 private boolean useUnicodeAsBoolean = true; 1250 1251 private BooleanConnectionProperty useUsageAdvisor = new BooleanConnectionProperty( 1252 "useUsageAdvisor", 1253 false, 1254 "Should the driver issue 'usage' warnings advising proper and efficient usage of JDBC and MySQL Connector/J to the log (true/false, defaults to 'false')?", 1255 "3.1.1", DEBUGING_PROFILING_CATEGORY, 10); 1256 1257 private boolean useUsageAdvisorAsBoolean = false; 1258 1259 private BooleanConnectionProperty yearIsDateType = new BooleanConnectionProperty( 1260 "yearIsDateType", 1261 true, 1262 "Should the JDBC driver treat the MySQL type \"YEAR\" as a java.sql.Date, or as a SHORT?", 1263 "3.1.9", MISC_CATEGORY, Integer.MIN_VALUE); 1264 1265 private StringConnectionProperty zeroDateTimeBehavior = new StringConnectionProperty( 1266 "zeroDateTimeBehavior", 1267 ZERO_DATETIME_BEHAVIOR_EXCEPTION, 1268 new String [] { ZERO_DATETIME_BEHAVIOR_EXCEPTION, 1269 ZERO_DATETIME_BEHAVIOR_ROUND, 1270 ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL }, 1271 "What should happen when the driver encounters DATETIME values that are composed " 1272 + "entirely of zeroes (used by MySQL to represent invalid dates)? " 1273 + "Valid values are '" 1274 + ZERO_DATETIME_BEHAVIOR_EXCEPTION 1275 + "', '" 1276 + ZERO_DATETIME_BEHAVIOR_ROUND 1277 + "' and '" 1278 + ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL + "'.", "3.1.4", 1279 MISC_CATEGORY, Integer.MIN_VALUE); 1280 1281 protected DriverPropertyInfo [] exposeAsDriverPropertyInfoInternal( 1282 Properties info, int slotsToReserve) throws SQLException { 1283 initializeProperties(info); 1284 1285 int numProperties = PROPERTY_LIST.size(); 1286 1287 int listSize = numProperties + slotsToReserve; 1288 1289 DriverPropertyInfo [] driverProperties = new DriverPropertyInfo [listSize]; 1290 1291 for (int i = slotsToReserve; i < listSize; i++) { 1292 java.lang.reflect.Field propertyField = (java.lang.reflect.Field ) PROPERTY_LIST 1293 .get(i - slotsToReserve); 1294 1295 try { 1296 ConnectionProperty propToExpose = (ConnectionProperty) propertyField 1297 .get(this); 1298 1299 if (info != null) { 1300 propToExpose.initializeFrom(info); 1301 } 1302 1303 propToExpose.syncDriverPropertyInfo(); 1304 driverProperties[i] = propToExpose; 1305 } catch (IllegalAccessException iae) { 1306 throw new SQLException ("Internal properties failure", 1307 SQLError.SQL_STATE_GENERAL_ERROR); 1308 } 1309 } 1310 1311 return driverProperties; 1312 } 1313 1314 protected Properties exposeAsProperties(Properties info) 1315 throws SQLException { 1316 if (info == null) { 1317 info = new Properties (); 1318 } 1319 1320 int numPropertiesToSet = PROPERTY_LIST.size(); 1321 1322 for (int i = 0; i < numPropertiesToSet; i++) { 1323 java.lang.reflect.Field propertyField = (java.lang.reflect.Field ) PROPERTY_LIST 1324 .get(i); 1325 1326 try { 1327 ConnectionProperty propToGet = (ConnectionProperty) propertyField 1328 .get(this); 1329 1330 Object propValue = propToGet.getValueAsObject(); 1331 1332 if (propValue != null) { 1333 info.setProperty(propToGet.getPropertyName(), propValue 1334 .toString()); 1335 } 1336 } catch (IllegalAccessException iae) { 1337 throw new SQLException ("Internal properties failure", 1338 SQLError.SQL_STATE_GENERAL_ERROR); 1339 } 1340 } 1341 1342 return info; 1343 } 1344 1345 1352 public String exposeAsXml() throws SQLException { 1353 StringBuffer xmlBuf = new StringBuffer (); 1354 xmlBuf.append("<ConnectionProperties>"); 1355 1356 int numPropertiesToSet = PROPERTY_LIST.size(); 1357 1358 int numCategories = PROPERTY_CATEGORIES.length; 1359 1360 Map propertyListByCategory = new HashMap (); 1361 1362 for (int i = 0; i < numCategories; i++) { 1363 propertyListByCategory.put(PROPERTY_CATEGORIES[i], new Map [] { 1364 new TreeMap (), new TreeMap () }); 1365 } 1366 1367 StringConnectionProperty userProp = new StringConnectionProperty( 1374 NonRegisteringDriver.USER_PROPERTY_KEY, null, 1375 "The user to connect as", "all", CONNECTION_AND_AUTH_CATEGORY, 1376 Integer.MIN_VALUE + 1); 1377 StringConnectionProperty passwordProp = new StringConnectionProperty( 1378 NonRegisteringDriver.PASSWORD_PROPERTY_KEY, null, 1379 "The password to use when connecting", "all", 1380 CONNECTION_AND_AUTH_CATEGORY, Integer.MIN_VALUE + 2); 1381 1382 Map [] connectionSortMaps = (Map []) propertyListByCategory 1383 .get(CONNECTION_AND_AUTH_CATEGORY); 1384 connectionSortMaps[0].put(new Integer (userProp.getOrder()), userProp); 1385 connectionSortMaps[0].put(new Integer (passwordProp.getOrder()), 1386 passwordProp); 1387 1388 try { 1389 for (int i = 0; i < numPropertiesToSet; i++) { 1390 java.lang.reflect.Field propertyField = (java.lang.reflect.Field ) PROPERTY_LIST 1391 .get(i); 1392 ConnectionProperty propToGet = (ConnectionProperty) propertyField 1393 .get(this); 1394 Map [] sortMaps = (Map []) propertyListByCategory.get(propToGet 1395 .getCategoryName()); 1396 int orderInCategory = propToGet.getOrder(); 1397 1398 if (orderInCategory == Integer.MIN_VALUE) { 1399 sortMaps[1].put(propToGet.getPropertyName(), propToGet); 1400 } else { 1401 sortMaps[0].put(new Integer (orderInCategory), propToGet); 1402 } 1403 } 1404 1405 for (int j = 0; j < numCategories; j++) { 1406 Map [] sortMaps = (Map []) propertyListByCategory 1407 .get(PROPERTY_CATEGORIES[j]); 1408 Iterator orderedIter = sortMaps[0].values().iterator(); 1409 Iterator alphaIter = sortMaps[1].values().iterator(); 1410 1411 xmlBuf.append("\n <PropertyCategory name=\""); 1412 xmlBuf.append(PROPERTY_CATEGORIES[j]); 1413 xmlBuf.append("\">"); 1414 1415 while (orderedIter.hasNext()) { 1416 ConnectionProperty propToGet = (ConnectionProperty) orderedIter 1417 .next(); 1418 propToGet.syncDriverPropertyInfo(); 1419 1420 xmlBuf.append("\n <Property name=\""); 1421 xmlBuf.append(propToGet.getPropertyName()); 1422 xmlBuf.append("\" required=\""); 1423 xmlBuf.append(propToGet.required ? "Yes" : "No"); 1424 1425 xmlBuf.append("\" default=\""); 1426 1427 if (propToGet.getDefaultValue() != null) { 1428 xmlBuf.append(propToGet.getDefaultValue()); 1429 } 1430 1431 xmlBuf.append("\" sortOrder=\""); 1432 xmlBuf.append(propToGet.getOrder()); 1433 xmlBuf.append("\" since=\""); 1434 xmlBuf.append(propToGet.sinceVersion); 1435 xmlBuf.append("\">\n"); 1436 xmlBuf.append(" "); 1437 xmlBuf.append(propToGet.description); 1438 xmlBuf.append("\n </Property>"); 1439 } 1440 1441 while (alphaIter.hasNext()) { 1442 ConnectionProperty propToGet = (ConnectionProperty) alphaIter 1443 .next(); 1444 propToGet.syncDriverPropertyInfo(); 1445 1446 xmlBuf.append("\n <Property name=\""); 1447 xmlBuf.append(propToGet.getPropertyName()); 1448 xmlBuf.append("\" required=\""); 1449 xmlBuf.append(propToGet.required ? "Yes" : "No"); 1450 1451 xmlBuf.append("\" default=\""); 1452 1453 if (propToGet.getDefaultValue() != null) { 1454 xmlBuf.append(propToGet.getDefaultValue()); 1455 } 1456 1457 xmlBuf.append("\" sortOrder=\"alpha\" since=\""); 1458 xmlBuf.append(propToGet.sinceVersion); 1459 xmlBuf.append("\">\n"); 1460 xmlBuf.append(" "); 1461 xmlBuf.append(propToGet.description); 1462 xmlBuf.append("\n </Property>"); 1463 } 1464 1465 xmlBuf.append("\n </PropertyCategory>"); 1466 } 1467 } catch (IllegalAccessException iae) { 1468 throw new SQLException ("Internal properties failure", 1469 SQLError.SQL_STATE_GENERAL_ERROR); 1470 } 1471 1472 xmlBuf.append("\n</ConnectionProperties>"); 1473 1474 return xmlBuf.toString(); 1475 } 1476 1477 1482 public boolean getAllowLoadLocalInfile() { 1483 return this.allowLoadLocalInfile.getValueAsBoolean(); 1484 } 1485 1486 1491 public boolean getAllowMultiQueries() { 1492 return this.allowMultiQueries.getValueAsBoolean(); 1493 } 1494 1495 1498 protected boolean getAllowNanAndInf() { 1499 return allowNanAndInf.getValueAsBoolean(); 1500 } 1501 1502 1505 public boolean getAllowUrlInLocalInfile() { 1506 return this.allowUrlInLocalInfile.getValueAsBoolean(); 1507 } 1508 1509 1512 public boolean getAlwaysSendSetIsolation() { 1513 return this.alwaysSendSetIsolation.getValueAsBoolean(); 1514 } 1515 1516 1519 public boolean getAutoDeserialize() { 1520 return autoDeserialize.getValueAsBoolean(); 1521 } 1522 1523 public boolean getAutoGenerateTestcaseScript() { 1524 return this.autoGenerateTestcaseScriptAsBoolean; 1525 } 1526 1527 1532 public boolean getAutoReconnectForPools() { 1533 return this.autoReconnectForPoolsAsBoolean; 1534 } 1535 1536 1539 public int getBlobSendChunkSize() { 1540 return blobSendChunkSize.getValueAsInt(); 1541 } 1542 1543 1548 public boolean getCacheCallableStatements() { 1549 return this.cacheCallableStatements.getValueAsBoolean(); 1550 } 1551 1552 1557 public boolean getCachePreparedStatements() { 1558 return ((Boolean ) this.cachePreparedStatements.getValueAsObject()) 1559 .booleanValue(); 1560 } 1561 1562 1567 public boolean getCacheResultSetMetadata() { 1568 return this.cacheResultSetMetaDataAsBoolean; 1569 } 1570 1571 1574 public boolean getCacheServerConfiguration() { 1575 return cacheServerConfiguration.getValueAsBoolean(); 1576 } 1577 1578 1583 public int getCallableStatementCacheSize() { 1584 return this.callableStatementCacheSize.getValueAsInt(); 1585 } 1586 1587 1592 public boolean getCapitalizeTypeNames() { 1593 return this.capitalizeTypeNames.getValueAsBoolean(); 1594 } 1595 1596 1601 public String getCharacterSetResults() { 1602 return this.characterSetResults.getValueAsString(); 1603 } 1604 1605 1610 public boolean getClobberStreamingResults() { 1611 return this.clobberStreamingResults.getValueAsBoolean(); 1612 } 1613 1614 1619 public String getConnectionCollation() { 1620 return this.connectionCollation.getValueAsString(); 1621 } 1622 1623 1628 public int getConnectTimeout() { 1629 return this.connectTimeout.getValueAsInt(); 1630 } 1631 1632 1637 public boolean getContinueBatchOnError() { 1638 return this.continueBatchOnError.getValueAsBoolean(); 1639 } 1640 1641 public boolean getCreateDatabaseIfNotExist() { 1642 return this.createDatabaseIfNotExist.getValueAsBoolean(); 1643 } 1644 1645 1648 public boolean getDontTrackOpenResources() { 1649 return this.dontTrackOpenResources.getValueAsBoolean(); 1650 } 1651 1652 1657 public boolean getDumpQueriesOnException() { 1658 return this.dumpQueriesOnException.getValueAsBoolean(); 1659 } 1660 1661 1664 public boolean getDynamicCalendars() { 1665 return this.dynamicCalendars.getValueAsBoolean(); 1666 } 1667 1668 1673 public boolean getElideSetAutoCommits() { 1674 return this.elideSetAutoCommits.getValueAsBoolean(); 1675 } 1676 1677 public boolean getEmptyStringsConvertToZero() { 1678 return this.emptyStringsConvertToZero.getValueAsBoolean(); 1679 } 1680 1681 1686 public boolean getEmulateLocators() { 1687 return this.emulateLocators.getValueAsBoolean(); 1688 } 1689 1690 1693 public boolean getEmulateUnsupportedPstmts() { 1694 return this.emulateUnsupportedPstmts.getValueAsBoolean(); 1695 } 1696 1697 1702 public boolean getEnablePacketDebug() { 1703 return this.enablePacketDebug.getValueAsBoolean(); 1704 } 1705 1706 1711 protected String getEncoding() { 1712 return this.characterEncodingAsString; 1713 } 1714 1715 1720 public boolean getExplainSlowQueries() { 1721 return this.explainSlowQueries.getValueAsBoolean(); 1722 } 1723 1724 1729 public boolean getFailOverReadOnly() { 1730 return this.failOverReadOnly.getValueAsBoolean(); 1731 } 1732 1733 1738 public boolean getGatherPerformanceMetrics() { 1739 return this.gatherPerformanceMetrics.getValueAsBoolean(); 1740 } 1741 1742 1747 protected boolean getHighAvailability() { 1748 return this.highAvailabilityAsBoolean; 1749 } 1750 1751 1754 public boolean getHoldResultsOpenOverStatementClose() { 1755 return holdResultsOpenOverStatementClose.getValueAsBoolean(); 1756 } 1757 1758 1763 public boolean getIgnoreNonTxTables() { 1764 return this.ignoreNonTxTables.getValueAsBoolean(); 1765 } 1766 1767 1772 public int getInitialTimeout() { 1773 return this.initialTimeout.getValueAsInt(); 1774 } 1775 1776 1781 public boolean getInteractiveClient() { 1782 return this.isInteractiveClient.getValueAsBoolean(); 1783 } 1784 1785 1790 public boolean getIsInteractiveClient() { 1791 return this.isInteractiveClient.getValueAsBoolean(); 1792 } 1793 1794 1799 public boolean getJdbcCompliantTruncation() { 1800 return this.jdbcCompliantTruncation.getValueAsBoolean(); 1801 } 1802 1803 1808 public String getLogger() { 1809 return this.loggerClassName.getValueAsString(); 1810 } 1811 1812 1817 public String getLoggerClassName() { 1818 return this.loggerClassName.getValueAsString(); 1819 } 1820 1821 1826 public boolean getLogSlowQueries() { 1827 return this.logSlowQueries.getValueAsBoolean(); 1828 } 1829 1830 public boolean getMaintainTimeStats() { 1831 return maintainTimeStatsAsBoolean; 1832 } 1833 1834 1839 public int getMaxQuerySizeToLog() { 1840 return this.maxQuerySizeToLog.getValueAsInt(); 1841 } 1842 1843 1848 public int getMaxReconnects() { 1849 return this.maxReconnects.getValueAsInt(); 1850 } 1851 1852 1857 public int getMaxRows() { 1858 return this.maxRowsAsInt; 1859 } 1860 1861 1867 public int getMetadataCacheSize() { 1868 return this.metadataCacheSize.getValueAsInt(); 1869 } 1870 1871 1874 public boolean getNoDatetimeStringSync() { 1875 return this.noDatetimeStringSync.getValueAsBoolean(); 1876 } 1877 1878 public boolean getNullCatalogMeansCurrent() { 1879 return this.nullCatalogMeansCurrent.getValueAsBoolean(); 1880 } 1881 1882 public boolean getNullNamePatternMatchesAll() { 1883 return this.nullNamePatternMatchesAll.getValueAsBoolean(); 1884 } 1885 1886 1891 public int getPacketDebugBufferSize() { 1892 return this.packetDebugBufferSize.getValueAsInt(); 1893 } 1894 1895 1900 public boolean getParanoid() { 1901 return this.paranoid.getValueAsBoolean(); 1902 } 1903 1904 1909 public boolean getPedantic() { 1910 return this.pedantic.getValueAsBoolean(); 1911 } 1912 1913 1918 public int getPreparedStatementCacheSize() { 1919 return ((Integer ) this.preparedStatementCacheSize.getValueAsObject()) 1920 .intValue(); 1921 } 1922 1923 1928 public int getPreparedStatementCacheSqlLimit() { 1929 return ((Integer ) this.preparedStatementCacheSqlLimit 1930 .getValueAsObject()).intValue(); 1931 } 1932 1933 1938 public boolean getProfileSql() { 1939 return this.profileSQLAsBoolean; 1940 } 1941 1942 1947 public boolean getProfileSQL() { 1948 return this.profileSQL.getValueAsBoolean(); 1949 } 1950 1951 1954 public String getPropertiesTransform() { 1955 return this.propertiesTransform.getValueAsString(); 1956 } 1957 1958 1963 public int getQueriesBeforeRetryMaster() { 1964 return this.queriesBeforeRetryMaster.getValueAsInt(); 1965 } 1966 1967 1972 public boolean getReconnectAtTxEnd() { 1973 return this.reconnectTxAtEndAsBoolean; 1974 } 1975 1976 1981 public boolean getRelaxAutoCommit() { 1982 return this.relaxAutoCommit.getValueAsBoolean(); 1983 } 1984 1985 1990 public int getReportMetricsIntervalMillis() { 1991 return this.reportMetricsIntervalMillis.getValueAsInt(); 1992 } 1993 1994 1999 public boolean getRequireSSL() { 2000 return this.requireSSL.getValueAsBoolean(); 2001 } 2002 2003 2006 public boolean getRollbackOnPooledClose() { 2007 return this.rollbackOnPooledClose.getValueAsBoolean(); 2008 } 2009 2010 2015 public boolean getRoundRobinLoadBalance() { 2016 return this.roundRobinLoadBalance.getValueAsBoolean(); 2017 } 2018 2019 2022 public boolean getRunningCTS13() { 2023 return this.runningCTS13.getValueAsBoolean(); 2024 } 2025 2026 2031 public int getSecondsBeforeRetryMaster() { 2032 return this.secondsBeforeRetryMaster.getValueAsInt(); 2033 } 2034 2035 2040 public String getServerTimezone() { 2041 return this.serverTimezone.getValueAsString(); 2042 } 2043 2044 2047 public String getSessionVariables() { 2048 return sessionVariables.getValueAsString(); 2049 } 2050 2051 2056 public int getSlowQueryThresholdMillis() { 2057 return this.slowQueryThresholdMillis.getValueAsInt(); 2058 } 2059 2060 2065 public String getSocketFactoryClassName() { 2066 return this.socketFactoryClassName.getValueAsString(); 2067 } 2068 2069 2074 public int getSocketTimeout() { 2075 return this.socketTimeout.getValueAsInt(); 2076 } 2077 2078 2083 public boolean getStrictFloatingPoint() { 2084 return this.strictFloatingPoint.getValueAsBoolean(); 2085 } 2086 2087 2092 public boolean getStrictUpdates() { 2093 return this.strictUpdates.getValueAsBoolean(); 2094 } 2095 2096 2099 public boolean getTinyInt1isBit() { 2100 return this.tinyInt1isBit.getValueAsBoolean(); 2101 } 2102 2103 2108 public boolean getTraceProtocol() { 2109 return this.traceProtocol.getValueAsBoolean(); 2110 } 2111 2112 public boolean getTransformedBitIsBoolean() { 2113 return this.transformedBitIsBoolean.getValueAsBoolean(); 2114 } 2115 2116 2121 public boolean getUseCompression() { 2122 return this.useCompression.getValueAsBoolean(); 2123 } 2124 2125 2128 public boolean getUseFastIntParsing() { 2129 return this.useFastIntParsing.getValueAsBoolean(); 2130 } 2131 2132 2137 public boolean getUseHostsInPrivileges() { 2138 return this.useHostsInPrivileges.getValueAsBoolean(); 2139 } 2140 2141 2144 public boolean getUseLocalSessionState() { 2145 return this.useLocalSessionState.getValueAsBoolean(); 2146 } 2147 2148 2153 public boolean getUseNewIo() { 2154 return this.useNewIo.getValueAsBoolean(); 2155 } 2156 2157 2160 public boolean getUseOldUTF8Behavior() { 2161 return this.useOldUTF8BehaviorAsBoolean; 2162 } 2163 2164 2167 public boolean getUseOnlyServerErrorMessages() { 2168 return this.useOnlyServerErrorMessages.getValueAsBoolean(); 2169 } 2170 2171 2174 public boolean getUseReadAheadInput() { 2175 return this.useReadAheadInput.getValueAsBoolean(); 2176 } 2177 2178 2183 public boolean getUseServerPreparedStmts() { 2184 return this.detectServerPreparedStmts.getValueAsBoolean(); 2185 } 2186 2187 2192 public boolean getUseSqlStateCodes() { 2193 return this.useSqlStateCodes.getValueAsBoolean(); 2194 } 2195 2196 2201 public boolean getUseSSL() { 2202 return this.useSSL.getValueAsBoolean(); 2203 } 2204 2205 2210 public boolean getUseStreamLengthsInPrepStmts() { 2211 return this.useStreamLengthsInPrepStmts.getValueAsBoolean(); 2212 } 2213 2214 2219 public boolean getUseTimezone() { 2220 return this.useTimezone.getValueAsBoolean(); 2221 } 2222 2223 2228 public boolean getUseUltraDevWorkAround() { 2229 return this.useUltraDevWorkAround.getValueAsBoolean(); 2230 } 2231 2232 2237 public boolean getUseUnbufferedInput() { 2238 return this.useUnbufferedInput.getValueAsBoolean(); 2239 } 2240 2241 2246 public boolean getUseUnicode() { 2247 return this.useUnicodeAsBoolean; 2248 } 2249 2250 2255 public boolean getUseUsageAdvisor() { 2256 return this.useUsageAdvisorAsBoolean; 2257 } 2258 2259 public boolean getYearIsDateType() { 2260 return this.yearIsDateType.getValueAsBoolean(); 2261 } 2262 2263 2266 public String getZeroDateTimeBehavior() { 2267 return this.zeroDateTimeBehavior.getValueAsString(); 2268 } 2269 2270 2280 protected void initializeFromRef(Reference ref) throws SQLException { 2281 int numPropertiesToSet = PROPERTY_LIST.size(); 2282 2283 for (int i = 0; i < numPropertiesToSet; i++) { 2284 java.lang.reflect.Field propertyField = (java.lang.reflect.Field ) PROPERTY_LIST 2285 .get(i); 2286 2287 try { 2288 ConnectionProperty propToSet = (ConnectionProperty) propertyField 2289 .get(this); 2290 2291 if (ref != null) { 2292 propToSet.initializeFrom(ref); 2293 } 2294 } catch (IllegalAccessException iae) { 2295 throw new SQLException ("Internal properties failure", 2296 SQLError.SQL_STATE_GENERAL_ERROR); 2297 } 2298 } 2299 2300 postInitialization(); 2301 } 2302 2303 2312 protected void initializeProperties(Properties info) throws SQLException { 2313 if (info != null) { 2314 String profileSqlLc = info.getProperty("profileSql"); 2316 2317 if (profileSqlLc != null) { 2318 info.put("profileSQL", profileSqlLc); 2319 } 2320 2321 Properties infoCopy = (Properties ) info.clone(); 2322 2323 infoCopy.remove(NonRegisteringDriver.HOST_PROPERTY_KEY); 2324 infoCopy.remove(NonRegisteringDriver.USER_PROPERTY_KEY); 2325 infoCopy.remove(NonRegisteringDriver.PASSWORD_PROPERTY_KEY); 2326 infoCopy.remove(NonRegisteringDriver.DBNAME_PROPERTY_KEY); 2327 infoCopy.remove(NonRegisteringDriver.PORT_PROPERTY_KEY); 2328 infoCopy.remove("profileSql"); 2329 2330 int numPropertiesToSet = PROPERTY_LIST.size(); 2331 2332 for (int i = 0; i < numPropertiesToSet; i++) { 2333 java.lang.reflect.Field propertyField = (java.lang.reflect.Field ) PROPERTY_LIST 2334 .get(i); 2335 2336 try { 2337 ConnectionProperty propToSet = (ConnectionProperty) propertyField 2338 .get(this); 2339 2340 propToSet.initializeFrom(infoCopy); 2341 } catch (IllegalAccessException iae) { 2342 throw new SQLException ( 2343 "Unable to initialize driver properties due to " 2344 + iae.toString(), 2345 SQLError.SQL_STATE_GENERAL_ERROR); 2346 } 2347 } 2348 2349 2365 postInitialization(); 2366 } 2367 } 2368 2369 protected void postInitialization() throws SQLException { 2370 2375 2376 if (getLogger() == STANDARD_LOGGER_NAME) { 2380 String environmentLoggerName = null; 2381 2382 try { 2383 environmentLoggerName = System 2384 .getProperty("com.mysql.jdbc.logger"); 2385 } catch (Throwable noAccessToSystemProperties) { 2386 environmentLoggerName = null; 2387 } 2388 2389 if (environmentLoggerName != null) { 2390 setLogger(environmentLoggerName); 2391 } else { 2392 try { 2393 Class.forName("org.apache.log4j.Level"); 2395 setLogger(Log4JLogger.class.getName()); 2396 } catch (Throwable t) { 2397 try { 2398 Class.forName("java.util.logging.Level"); 2400 setLogger(Jdk14Logger.class.getName()); 2401 } catch (Throwable t2) { 2402 setLogger(STANDARD_LOGGER_NAME); 2404 } 2405 } 2406 } 2407 } 2408 2409 if (this.profileSql.getValueAsObject() != null) { 2411 this.profileSQL.initializeFrom(this.profileSql.getValueAsObject() 2412 .toString()); 2413 } 2414 2415 this.reconnectTxAtEndAsBoolean = ((Boolean ) this.reconnectAtTxEnd 2416 .getValueAsObject()).booleanValue(); 2417 2418 if (this.getMaxRows() == 0) { 2420 this.maxRows.setValueAsObject(new Integer (-1)); 2423 } 2424 2425 String testEncoding = this.getEncoding(); 2429 2430 if (testEncoding != null) { 2431 try { 2434 String testString = "abc"; 2435 testString.getBytes(testEncoding); 2436 } catch (UnsupportedEncodingException UE) { 2437 throw new SQLException ("Unsupported character " + "encoding '" 2438 + testEncoding + "'.", "0S100"); 2439 } 2440 } 2441 2442 if (((Boolean ) this.cacheResultSetMetadata.getValueAsObject()) 2446 .booleanValue()) { 2447 try { 2448 Class.forName("java.util.LinkedHashMap"); 2449 } catch (ClassNotFoundException cnfe) { 2450 this.cacheResultSetMetadata.setValue(false); 2451 } 2452 } 2453 2454 this.cacheResultSetMetaDataAsBoolean = this.cacheResultSetMetadata 2455 .getValueAsBoolean(); 2456 this.useUnicodeAsBoolean = this.useUnicode.getValueAsBoolean(); 2457 this.characterEncodingAsString = ((String ) this.characterEncoding 2458 .getValueAsObject()); 2459 this.highAvailabilityAsBoolean = this.autoReconnect.getValueAsBoolean(); 2460 this.autoReconnectForPoolsAsBoolean = this.autoReconnectForPools 2461 .getValueAsBoolean(); 2462 this.maxRowsAsInt = ((Integer ) this.maxRows.getValueAsObject()) 2463 .intValue(); 2464 this.profileSQLAsBoolean = this.profileSQL.getValueAsBoolean(); 2465 this.useUsageAdvisorAsBoolean = this.useUsageAdvisor 2466 .getValueAsBoolean(); 2467 this.useOldUTF8BehaviorAsBoolean = this.useOldUTF8Behavior 2468 .getValueAsBoolean(); 2469 this.autoGenerateTestcaseScriptAsBoolean = this.autoGenerateTestcaseScript 2470 .getValueAsBoolean(); 2471 this.maintainTimeStatsAsBoolean = this.maintainTimeStats 2472 .getValueAsBoolean(); 2473 } 2474 2475 2480 public void setAllowLoadLocalInfile(boolean property) { 2481 this.allowLoadLocalInfile.setValue(property); 2482 } 2483 2484 2489 public void setAllowMultiQueries(boolean property) { 2490 this.allowMultiQueries.setValue(property); 2491 } 2492 2493 2497 protected void setAllowNanAndInf(boolean flag) { 2498 this.allowNanAndInf.setValue(flag); 2499 } 2500 2501 2505 public void setAllowUrlInLocalInfile(boolean flag) { 2506 this.allowUrlInLocalInfile.setValue(flag); 2507 } 2508 2509 2513 public void setAlwaysSendSetIsolation(boolean flag) { 2514 this.alwaysSendSetIsolation.setValue(flag); 2515 } 2516 2517 2521 public void setAutoDeserialize(boolean flag) { 2522 this.autoDeserialize.setValue(flag); 2523 } 2524 2525 public void setAutoGenerateTestcaseScript(boolean flag) { 2526 this.autoGenerateTestcaseScript.setValue(flag); 2527 this.autoGenerateTestcaseScriptAsBoolean = this.autoGenerateTestcaseScript 2528 .getValueAsBoolean(); 2529 } 2530 2531 2537 public void setAutoReconnect(boolean flag) { 2538 this.autoReconnect.setValue(flag); 2539 } 2540 2541 2546 public void setAutoReconnectForConnectionPools(boolean property) { 2547 this.autoReconnectForPools.setValue(property); 2548 this.autoReconnectForPoolsAsBoolean = this.autoReconnectForPools 2549 .getValueAsBoolean(); 2550 } 2551 2552 2558 public void setAutoReconnectForPools(boolean flag) { 2559 this.autoReconnectForPools.setValue(flag); 2560 } 2561 2562 2566 public void setBlobSendChunkSize(String value) throws SQLException { 2567 this.blobSendChunkSize.setValue(value); 2568 } 2569 2570 2576 public void setCacheCallableStatements(boolean flag) { 2577 this.cacheCallableStatements.setValue(flag); 2578 } 2579 2580 2586 public void setCachePreparedStatements(boolean flag) { 2587 this.cachePreparedStatements.setValue(flag); 2588 } 2589 2590 2595 public void setCacheResultSetMetadata(boolean property) { 2596 this.cacheResultSetMetadata.setValue(property); 2597 this.cacheResultSetMetaDataAsBoolean = this.cacheResultSetMetadata 2598 .getValueAsBoolean(); 2599 } 2600 2601 2605 public void setCacheServerConfiguration(boolean flag) { 2606 this.cacheServerConfiguration.setValue(flag); 2607 } 2608 2609 2616 public void setCallableStatementCacheSize(int size) { 2617 this.callableStatementCacheSize.setValue(size); 2618 } 2619 2620 2625 public void setCapitalizeDBMDTypes(boolean property) { 2626 this.capitalizeTypeNames.setValue(property); 2627 } 2628 2629 2635 public void setCapitalizeTypeNames(boolean flag) { 2636 this.capitalizeTypeNames.setValue(flag); 2637 } 2638 2639 2645 public void setCharacterEncoding(String encoding) { 2646 this.characterEncoding.setValue(encoding); 2647 } 2648 2649 2655 public void setCharacterSetResults(String characterSet) { 2656 this.characterSetResults.setValue(characterSet); 2657 } 2658 2659 2665 public void setClobberStreamingResults(boolean flag) { 2666 this.clobberStreamingResults.setValue(flag); 2667 } 2668 2669 2675 public void setConnectionCollation(String collation) { 2676 this.connectionCollation.setValue(collation); 2677 } 2678 2679 2684 public void setConnectTimeout(int timeoutMs) { 2685 this.connectTimeout.setValue(timeoutMs); 2686 } 2687 2688 2693 public void setContinueBatchOnError(boolean property) { 2694 this.continueBatchOnError.setValue(property); 2695 } 2696 2697 public void setCreateDatabaseIfNotExist(boolean flag) { 2698 this.createDatabaseIfNotExist.setValue(flag); 2699 } 2700 2701 2706 public void setDetectServerPreparedStmts(boolean property) { 2707 this.detectServerPreparedStmts.setValue(property); 2708 } 2709 2710 2714 public void setDontTrackOpenResources(boolean flag) { 2715 this.dontTrackOpenResources.setValue(flag); 2716 } 2717 2718 2724 public void setDumpQueriesOnException(boolean flag) { 2725 this.dumpQueriesOnException.setValue(flag); 2726 } 2727 2728 2732 public void setDynamicCalendars(boolean flag) { 2733 this.dynamicCalendars.setValue(flag); 2734 } 2735 2736 2742 public void setElideSetAutoCommits(boolean flag) { 2743 this.elideSetAutoCommits.setValue(flag); 2744 } 2745 2746 public void setEmptyStringsConvertToZero(boolean flag) { 2747 this.emptyStringsConvertToZero.setValue(flag); 2748 } 2749 2750 2755 public void setEmulateLocators(boolean property) { 2756 this.emulateLocators.setValue(property); 2757 } 2758 2759 2763 public void setEmulateUnsupportedPstmts(boolean flag) { 2764 this.emulateUnsupportedPstmts.setValue(flag); 2765 } 2766 2767 2773 public void setEnablePacketDebug(boolean flag) { 2774 this.enablePacketDebug.setValue(flag); 2775 } 2776 2777 2782 public void setEncoding(String property) { 2783 this.characterEncoding.setValue(property); 2784 this.characterEncodingAsString = this.characterEncoding 2785 .getValueAsString(); 2786 } 2787 2788 2794 public void setExplainSlowQueries(boolean flag) { 2795 this.explainSlowQueries.setValue(flag); 2796 } 2797 2798 2804 public void setFailOverReadOnly(boolean flag) { 2805 this.failOverReadOnly.setValue(flag); 2806 } 2807 2808 2814 public void setGatherPerformanceMetrics(boolean flag) { 2815 this.gatherPerformanceMetrics.setValue(flag); 2816 } 2817 2818 2823 protected void setHighAvailability(boolean property) { 2824 this.autoReconnect.setValue(property); 2825 this.highAvailabilityAsBoolean = this.autoReconnect.getValueAsBoolean(); 2826 } 2827 2828 2832 public void setHoldResultsOpenOverStatementClose(boolean flag) { 2833 this.holdResultsOpenOverStatementClose.setValue(flag); 2834 } 2835 2836 2841 public void setIgnoreNonTxTables(boolean property) { 2842 this.ignoreNonTxTables.setValue(property); 2843 } 2844 2845 2850 public void setInitialTimeout(int property) { 2851 this.initialTimeout.setValue(property); 2852 } 2853 2854 2859 public void setIsInteractiveClient(boolean property) { 2860 this.isInteractiveClient.setValue(property); 2861 } 2862 2863 2869 public void setJdbcCompliantTruncation(boolean flag) { 2870 this.jdbcCompliantTruncation.setValue(flag); 2871 } 2872 2873 2878 public void setLogger(String property) { 2879 this.loggerClassName.setValueAsObject(property); 2880 } 2881 2882 2888 public void setLoggerClassName(String className) { 2889 this.loggerClassName.setValue(className); 2890 } 2891 2892 2898 public void setLogSlowQueries(boolean flag) { 2899 this.logSlowQueries.setValue(flag); 2900 } 2901 2902 public void setMaintainTimeStats(boolean flag) { 2903 this.maintainTimeStats.setValue(flag); 2904 this.maintainTimeStatsAsBoolean = this.maintainTimeStats 2905 .getValueAsBoolean(); 2906 } 2907 2908 2914 public void setMaxQuerySizeToLog(int sizeInBytes) { 2915 this.maxQuerySizeToLog.setValue(sizeInBytes); 2916 } 2917 2918 2923 public void setMaxReconnects(int property) { 2924 this.maxReconnects.setValue(property); 2925 } 2926 2927 2932 public void setMaxRows(int property) { 2933 this.maxRows.setValue(property); 2934 this.maxRowsAsInt = this.maxRows.getValueAsInt(); 2935 } 2936 2937 2944 public void setMetadataCacheSize(int value) { 2945 this.metadataCacheSize.setValue(value); 2946 } 2947 2948 2952 public void setNoDatetimeStringSync(boolean flag) { 2953 this.noDatetimeStringSync.setValue(flag); 2954 } 2955 2956 public void setNullCatalogMeansCurrent(boolean value) { 2957 this.nullCatalogMeansCurrent.setValue(value); 2958 } 2959 2960 public void setNullNamePatternMatchesAll(boolean value) { 2961 this.nullNamePatternMatchesAll.setValue(value); 2962 } 2963 2964 2970 public void setPacketDebugBufferSize(int size) { 2971 this.packetDebugBufferSize.setValue(size); 2972 } 2973 2974 2979 public void setParanoid(boolean property) { 2980 this.paranoid.setValue(property); 2981 } 2982 2983 2988 public void setPedantic(boolean property) { 2989 this.pedantic.setValue(property); 2990 } 2991 2992 2998 public void setPreparedStatementCacheSize(int cacheSize) { 2999 this.preparedStatementCacheSize.setValue(cacheSize); 3000 } 3001 3002 3008 public void setPreparedStatementCacheSqlLimit(int cacheSqlLimit) { 3009 this.preparedStatementCacheSqlLimit.setValue(cacheSqlLimit); 3010 } 3011 3012 3017 public void setProfileSql(boolean property) { 3018 this.profileSQL.setValue(property); 3019 this.profileSQLAsBoolean = this.profileSQL.getValueAsBoolean(); 3020 } 3021 3022 3028 public void setProfileSQL(boolean flag) { 3029 this.profileSQL.setValue(flag); 3030 } 3031 3032 3036 public void setPropertiesTransform(String value) { 3037 this.propertiesTransform.setValue(value); 3038 } 3039 3040 3045 public void setQueriesBeforeRetryMaster(int property) { 3046 this.queriesBeforeRetryMaster.setValue(property); 3047 } 3048 3049 3054 public void setReconnectAtTxEnd(boolean property) { 3055 this.reconnectAtTxEnd.setValue(property); 3056 this.reconnectTxAtEndAsBoolean = this.reconnectAtTxEnd 3057 .getValueAsBoolean(); 3058 } 3059 3060 3065 public void setRelaxAutoCommit(boolean property) { 3066 this.relaxAutoCommit.setValue(property); 3067 } 3068 3069 3075 public void setReportMetricsIntervalMillis(int millis) { 3076 this.reportMetricsIntervalMillis.setValue(millis); 3077 } 3078 3079 3084 public void setRequireSSL(boolean property) { 3085 this.requireSSL.setValue(property); 3086 } 3087 3088 3092 public void setRollbackOnPooledClose(boolean flag) { 3093 this.rollbackOnPooledClose.setValue(flag); 3094 } 3095 3096 3102 public void setRoundRobinLoadBalance(boolean flag) { 3103 this.roundRobinLoadBalance.setValue(flag); 3104 } 3105 3106 3110 public void setRunningCTS13(boolean flag) { 3111 this.runningCTS13.setValue(flag); 3112 } 3113 3114 3119 public void setSecondsBeforeRetryMaster(int property) { 3120 this.secondsBeforeRetryMaster.setValue(property); 3121 } 3122 3123 3129 public void setServerTimezone(String property) { 3130 this.serverTimezone.setValue(property); 3131 } 3132 3133 3137 public void setSessionVariables(String variables) { 3138 this.sessionVariables.setValue(variables); 3139 } 3140 3141 3147 public void setSlowQueryThresholdMillis(int millis) { 3148 this.slowQueryThresholdMillis.setValue(millis); 3149 } 3150 3151 3156 public void setSocketFactoryClassName(String property) { 3157 this.socketFactoryClassName.setValue(property); 3158 } 3159 3160 3165 public void setSocketTimeout(int property) { 3166 this.socketTimeout.setValue(property); 3167 } 3168 3169 3174 public void setStrictFloatingPoint(boolean property) { 3175 this.strictFloatingPoint.setValue(property); 3176 } 3177 3178 3183 public void setStrictUpdates(boolean property) { 3184 this.strictUpdates.setValue(property); 3185 } 3186 3187 3191 public void setTinyInt1isBit(boolean flag) { 3192 this.tinyInt1isBit.setValue(flag); 3193 } 3194 3195 3201 public void setTraceProtocol(boolean flag) { 3202 this.traceProtocol.setValue(flag); 3203 } 3204 3205 public void setTransformedBitIsBoolean(boolean flag) { 3206 this.transformedBitIsBoolean.setValue(flag); 3207 } 3208 3209 3214 public void setUseCompression(boolean property) { 3215 this.useCompression.setValue(property); 3216 } 3217 3218 3222 public void setUseFastIntParsing(boolean flag) { 3223 this.useFastIntParsing.setValue(flag); 3224 } 3225 3226 3231 public void setUseHostsInPrivileges(boolean property) { 3232 this.useHostsInPrivileges.setValue(property); 3233 } 3234 3235 3239 public void setUseLocalSessionState(boolean flag) { 3240 this.useLocalSessionState.setValue(flag); 3241 } 3242 3243 3248 public void setUseNewIo(boolean property) { 3249 this.useNewIo.setValue(property); 3250 } 3251 3252 3256 public void setUseOldUTF8Behavior(boolean flag) { 3257 this.useOldUTF8Behavior.setValue(flag); 3258 this.useOldUTF8BehaviorAsBoolean = this.useOldUTF8Behavior 3259 .getValueAsBoolean(); 3260 } 3261 3262 3266 public void setUseOnlyServerErrorMessages(boolean flag) { 3267 this.useOnlyServerErrorMessages.setValue(flag); 3268 } 3269 3270 3274 public void setUseReadAheadInput(boolean flag) { 3275 this.useReadAheadInput.setValue(flag); 3276 } 3277 3278 3284 public void setUseServerPreparedStmts(boolean flag) { 3285 this.detectServerPreparedStmts.setValue(flag); 3286 } 3287 3288 3294 public void setUseSqlStateCodes(boolean flag) { 3295 this.useSqlStateCodes.setValue(flag); 3296 } 3297 3298 3303 public void setUseSSL(boolean property) { 3304 this.useSSL.setValue(property); 3305 } 3306 3307 3312 public void setUseStreamLengthsInPrepStmts(boolean property) { 3313 this.useStreamLengthsInPrepStmts.setValue(property); 3314 } 3315 3316 3321 public void setUseTimezone(boolean property) { 3322 this.useTimezone.setValue(property); 3323 } 3324 3325 3330 public void setUseUltraDevWorkAround(boolean property) { 3331 this.useUltraDevWorkAround.setValue(property); 3332 } 3333 3334 3340 public void setUseUnbufferedInput(boolean flag) { 3341 this.useUnbufferedInput.setValue(flag); 3342 } 3343 3344 3350 public void setUseUnicode(boolean flag) { 3351 this.useUnicode.setValue(flag); 3352 this.useUnicodeAsBoolean = this.useUnicode.getValueAsBoolean(); 3353 } 3354 3355 3361 public void setUseUsageAdvisor(boolean useUsageAdvisorFlag) { 3362 this.useUsageAdvisor.setValue(useUsageAdvisorFlag); 3363 this.useUsageAdvisorAsBoolean = this.useUsageAdvisor 3364 .getValueAsBoolean(); 3365 } 3366 3367 public void setYearIsDateType(boolean flag) { 3368 this.yearIsDateType.setValue(flag); 3369 } 3370 3371 3375 public void setZeroDateTimeBehavior(String behavior) { 3376 this.zeroDateTimeBehavior.setValue(behavior); 3377 } 3378 3379 protected void storeToRef(Reference ref) throws SQLException { 3380 int numPropertiesToSet = PROPERTY_LIST.size(); 3381 3382 for (int i = 0; i < numPropertiesToSet; i++) { 3383 java.lang.reflect.Field propertyField = (java.lang.reflect.Field ) PROPERTY_LIST 3384 .get(i); 3385 3386 try { 3387 ConnectionProperty propToStore = (ConnectionProperty) propertyField 3388 .get(this); 3389 3390 if (ref != null) { 3391 propToStore.storeTo(ref); 3392 } 3393 } catch (IllegalAccessException iae) { 3394 throw new SQLException ("Huh?"); 3395 } 3396 } 3397 } 3398 3399 3404 protected boolean useUnbufferedInput() { 3405 return this.useUnbufferedInput.getValueAsBoolean(); 3406 } 3407} 3408 | Popular Tags |