📄 connectionproperties.java
字号:
true, "Don't prepend 'standard' SQLState error messages to error messages returned by the server.", "3.0.15", MISC_CATEGORY, Integer.MIN_VALUE); private BooleanConnectionProperty useReadAheadInput = new BooleanConnectionProperty( "useReadAheadInput", true, "Use newer, optimized non-blocking, buffered input stream when reading from the server?", "3.1.5", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); private BooleanConnectionProperty useSqlStateCodes = new BooleanConnectionProperty( "useSqlStateCodes", true, "Use SQL Standard state codes instead of 'legacy' X/Open/SQL state codes (true/false), default is 'true'", "3.1.3", MISC_CATEGORY, Integer.MIN_VALUE); private BooleanConnectionProperty useSSL = new BooleanConnectionProperty( "useSSL", false, "Use SSL when communicating with the server (true/false), defaults to 'false'", "3.0.2", SECURITY_CATEGORY, 2); private BooleanConnectionProperty useStreamLengthsInPrepStmts = new BooleanConnectionProperty( "useStreamLengthsInPrepStmts", true, "Honor stream length parameter in " + "PreparedStatement/ResultSet.setXXXStream() method calls (true/false, defaults to 'true')?", "3.0.2", MISC_CATEGORY, Integer.MIN_VALUE); private BooleanConnectionProperty useTimezone = new BooleanConnectionProperty( "useTimezone", false, "Convert time/date types between client and server timezones (true/false, defaults to 'false')?", "3.0.2", MISC_CATEGORY, Integer.MIN_VALUE); private BooleanConnectionProperty useUltraDevWorkAround = new BooleanConnectionProperty( "ultraDevHack", false, "Create PreparedStatements for prepareCall() when required, because UltraDev " + " is broken and issues a prepareCall() for _all_ statements? (true/false, defaults to 'false')", "2.0.3", MISC_CATEGORY, Integer.MIN_VALUE); private BooleanConnectionProperty useUnbufferedInput = new BooleanConnectionProperty( "useUnbufferedInput", true, "Don't use BufferedInputStream for reading data from the server", "3.0.11", MISC_CATEGORY, Integer.MIN_VALUE); private BooleanConnectionProperty useUnicode = new BooleanConnectionProperty( "useUnicode", false, "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'", "1.1g", MISC_CATEGORY, 0); // Cache these values, they are 'hot' private boolean useUnicodeAsBoolean = true; private BooleanConnectionProperty useUsageAdvisor = new BooleanConnectionProperty( "useUsageAdvisor", false, "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')?", "3.1.1", DEBUGING_PROFILING_CATEGORY, 10); private boolean useUsageAdvisorAsBoolean = false; private BooleanConnectionProperty yearIsDateType = new BooleanConnectionProperty( "yearIsDateType", true, "Should the JDBC driver treat the MySQL type \"YEAR\" as a java.sql.Date, or as a SHORT?", "3.1.9", MISC_CATEGORY, Integer.MIN_VALUE); private StringConnectionProperty zeroDateTimeBehavior = new StringConnectionProperty( "zeroDateTimeBehavior", ZERO_DATETIME_BEHAVIOR_EXCEPTION, new String[] { ZERO_DATETIME_BEHAVIOR_EXCEPTION, ZERO_DATETIME_BEHAVIOR_ROUND, ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL }, "What should happen when the driver encounters DATETIME values that are composed " + "entirely of zeroes (used by MySQL to represent invalid dates)? " + "Valid values are '" + ZERO_DATETIME_BEHAVIOR_EXCEPTION + "', '" + ZERO_DATETIME_BEHAVIOR_ROUND + "' and '" + ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL + "'.", "3.1.4", MISC_CATEGORY, Integer.MIN_VALUE); protected DriverPropertyInfo[] exposeAsDriverPropertyInfoInternal( Properties info, int slotsToReserve) throws SQLException { initializeProperties(info); int numProperties = PROPERTY_LIST.size(); int listSize = numProperties + slotsToReserve; DriverPropertyInfo[] driverProperties = new DriverPropertyInfo[listSize]; for (int i = slotsToReserve; i < listSize; i++) { java.lang.reflect.Field propertyField = (java.lang.reflect.Field) PROPERTY_LIST .get(i - slotsToReserve); try { ConnectionProperty propToExpose = (ConnectionProperty) propertyField .get(this); if (info != null) { propToExpose.initializeFrom(info); } propToExpose.syncDriverPropertyInfo(); driverProperties[i] = propToExpose; } catch (IllegalAccessException iae) { throw new SQLException("Internal properties failure", SQLError.SQL_STATE_GENERAL_ERROR); } } return driverProperties; } protected Properties exposeAsProperties(Properties info) throws SQLException { if (info == null) { info = new Properties(); } int numPropertiesToSet = PROPERTY_LIST.size(); for (int i = 0; i < numPropertiesToSet; i++) { java.lang.reflect.Field propertyField = (java.lang.reflect.Field) PROPERTY_LIST .get(i); try { ConnectionProperty propToGet = (ConnectionProperty) propertyField .get(this); Object propValue = propToGet.getValueAsObject(); if (propValue != null) { info.setProperty(propToGet.getPropertyName(), propValue .toString()); } } catch (IllegalAccessException iae) { throw new SQLException("Internal properties failure", SQLError.SQL_STATE_GENERAL_ERROR); } } return info; } /** * Returns a description of the connection properties as an XML document. * * @return the connection properties as an XML document. * @throws SQLException * if an error occurs. */ public String exposeAsXml() throws SQLException { StringBuffer xmlBuf = new StringBuffer(); xmlBuf.append("<ConnectionProperties>"); int numPropertiesToSet = PROPERTY_LIST.size(); int numCategories = PROPERTY_CATEGORIES.length; Map propertyListByCategory = new HashMap(); for (int i = 0; i < numCategories; i++) { propertyListByCategory.put(PROPERTY_CATEGORIES[i], new Map[] { new TreeMap(), new TreeMap() }); } // // The following properties are not exposed as 'normal' properties, but // they are // settable nonetheless, so we need to have them documented, make sure // that they sort 'first' as #1 and #2 in the category // StringConnectionProperty userProp = new StringConnectionProperty( NonRegisteringDriver.USER_PROPERTY_KEY, null, "The user to connect as", "all", CONNECTION_AND_AUTH_CATEGORY, Integer.MIN_VALUE + 1); StringConnectionProperty passwordProp = new StringConnectionProperty( NonRegisteringDriver.PASSWORD_PROPERTY_KEY, null, "The password to use when connecting", "all", CONNECTION_AND_AUTH_CATEGORY, Integer.MIN_VALUE + 2); Map[] connectionSortMaps = (Map[]) propertyListByCategory .get(CONNECTION_AND_AUTH_CATEGORY); connectionSortMaps[0].put(new Integer(userProp.getOrder()), userProp); connectionSortMaps[0].put(new Integer(passwordProp.getOrder()), passwordProp); try { for (int i = 0; i < numPropertiesToSet; i++) { java.lang.reflect.Field propertyField = (java.lang.reflect.Field) PROPERTY_LIST .get(i); ConnectionProperty propToGet = (ConnectionProperty) propertyField .get(this); Map[] sortMaps = (Map[]) propertyListByCategory.get(propToGet .getCategoryName()); int orderInCategory = propToGet.getOrder(); if (orderInCategory == Integer.MIN_VALUE) { sortMaps[1].put(propToGet.getPropertyName(), propToGet); } else { sortMaps[0].put(new Integer(orderInCategory), propToGet); } } for (int j = 0; j < numCategories; j++) { Map[] sortMaps = (Map[]) propertyListByCategory .get(PROPERTY_CATEGORIES[j]); Iterator orderedIter = sortMaps[0].values().iterator(); Iterator alphaIter = sortMaps[1].values().iterator(); xmlBuf.append("\n <PropertyCategory name=\""); xmlBuf.append(PROPERTY_CATEGORIES[j]); xmlBuf.append("\">"); while (orderedIter.hasNext()) { ConnectionProperty propToGet = (ConnectionProperty) orderedIter .next(); propToGet.syncDriverPropertyInfo(); xmlBuf.append("\n <Property name=\""); xmlBuf.append(propToGet.getPropertyName()); xmlBuf.append("\" required=\""); xmlBuf.append(propToGet.required ? "Yes" : "No"); xmlBuf.append("\" default=\""); if (propToGet.getDefaultValue() != null) { xmlBuf.append(propToGet.getDefaultValue()); } xmlBuf.append("\" sortOrder=\""); xmlBuf.append(propToGet.getOrder()); xmlBuf.append("\" since=\""); xmlBuf.append(propToGet.sinceVersion); xmlBuf.append("\">\n"); xmlBuf.append(" "); xmlBuf.append(propToGet.description); xmlBuf.append("\n </Property>"); } while (alphaIter.hasNext()) { ConnectionProperty propToGet = (ConnectionProperty) alphaIter .next(); propToGet.syncDriverPropertyInfo(); xmlBuf.append("\n <Property name=\""); xmlBuf.append(propToGet.getPropertyName()); xmlBuf.append("\" required=\""); xmlBuf.append(propToGet.required ? "Yes" : "No"); xmlBuf.append("\" default=\""); if (propToGet.getDefaultValue() != null) { xmlBuf.append(propToGet.getDefaultValue()); } xmlBuf.append("\" sortOrder=\"alpha\" since=\""); xmlBuf.append(propToGet.sinceVersion); xmlBuf.append("\">\n"); xmlBuf.append(" "); xmlBuf.append(propToGet.description); xmlBuf.append("\n </Property>"); } xmlBuf.append("\n </PropertyCategory>"); } } catch (IllegalAccessException iae) { throw new SQLException("Internal properties failure", SQLError.SQL_STATE_GENERAL_ERROR); } xmlBuf.append("\n</ConnectionProperties>"); return xmlBuf.toString(); } /** * DOCUMENT ME! * * @return */ public boolean getAllowLoadLocalInfile() { return this.allowLoadLocalInfile.getValueAsBoolean(); } /** * DOCUMENT ME! * * @return */ public boolean getAllowMultiQueries() { return this.allowMultiQueries.getValueAsBoolean(); } /** * @return Returns the allowNanAndInf. */ protected boolean getAllowNanAndInf() { return allowNanAndInf.getValueAsBoolean(); } /** * @return Returns the allowUrlInLocalInfile. */ public boolean getAllowUrlInLocalInfile() { return this.allowUrlInLocalInfile.getValueAsBoolean(); } /** * @return Returns the alwaysSendSetIsolation. */ public boolean getAlwaysSendSetIsolation() { return this.alwaysSendSetIsolation.getValueAsBoolean(); } /** * @return Returns the autoDeserialize. */ public boolean getAutoDeserialize() { return autoDeserialize.getValueAsBoolean(); } public boolean getAutoGenerateTestcaseScript() { return this.autoGenerateTestcaseScriptAsBoolean; } /** * DOCUMENT ME! * * @return */ public boolean getAutoReconnectForPools() { return this.autoReconnectForPoolsAsBoolean; } /** * @return Returns the blobSendChunkSize. */ public int getBlobSendChunkSize() { return blobSendChunkSize.getValueAsInt(); } /** * DOCUMENT ME! * * @return Returns if cacheCallableStatements is enabled */ public boolean getCacheCallableStatements() { return this.cacheCallableStatements.getValueAsBoolean(); } /** * DOCUMENT ME! * * @return Returns the cachePreparedStatements. */ public boolean getCachePreparedStatements() { return ((Boolean) this.cachePreparedStatements.getValueAsObject()) .booleanValue(); } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public boolean getCacheResultSetMetadata() { return this.cacheResultSetMetaDataAsBoolean; } /** * @return Returns the cacheServerConfiguration. */ public boolean getCacheServerConfiguration() { return cacheServerConfiguration.getValueAsBoolean(); } /** * DOCUMENT ME! * * @return Returns the callableStatementCacheSize. */ public int getCallableStatementCacheSize() { return this.callableStatementCacheSize.getValueAsInt(); } /** * DOCUMENT ME! * * @return */ public boolean getCapitalizeTypeNames() { return this.capitalizeTypeNames.getValueAsBoolean(); } /** * DOCUMENT ME!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -