⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connection.java

📁 开发MySql数据库的最新JDBC驱动。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		public void setTime(String arg0, Time arg1, Calendar arg2)				throws SQLException {			throw new NotImplemented();		}		public void setTimestamp(int p1, final java.sql.Timestamp p2)				throws SQLException {			this.delegate.setTimestamp(p1, p2);		}		public void setTimestamp(int p1, final java.sql.Timestamp p2,				final java.util.Calendar p3) throws SQLException {			this.delegate.setTimestamp(p1, p2, p3);		}		/**		 * @see CallableStatement#setTimestamp(String, Timestamp)		 */		public void setTimestamp(String arg0, Timestamp arg1)				throws SQLException {			throw new NotImplemented();		}		/**		 * @see CallableStatement#setTimestamp(String, Timestamp, Calendar)		 */		public void setTimestamp(String arg0, Timestamp arg1, Calendar arg2)				throws SQLException {			throw new NotImplemented();		}		/**		 * DOCUMENT ME!		 * 		 * @param p1		 *            DOCUMENT ME!		 * @param p2		 *            DOCUMENT ME!		 * @param p3		 *            DOCUMENT ME!		 * @throws SQLException		 *             DOCUMENT ME!		 * @deprecated		 */		public void setUnicodeStream(int p1, final java.io.InputStream p2,				int p3) throws SQLException {			this.delegate.setUnicodeStream(p1, p2, p3);		}		/**		 * @see PreparedStatement#setURL(int, URL)		 */		public void setURL(int arg0, URL arg1) throws SQLException {			this.delegate.setURL(arg0, arg1);		}		/**		 * @see CallableStatement#setURL(String, URL)		 */		public void setURL(String arg0, URL arg1) throws SQLException {			throw new NotImplemented();		}		public boolean wasNull() throws SQLException {			throw SQLError.createSQLException("Not supported");		}	}	/**	 * Marker for character set converter not being available (not written,	 * multibyte, etc) Used to prevent multiple instantiation requests.	 */	private static final Object CHARSET_CONVERTER_NOT_AVAILABLE_MARKER = new Object();	/**	 * The mapping between MySQL charset names and Java charset names.	 * Initialized by loadCharacterSetMapping()	 */	public static Map charsetMap;	/** Default logger class name */	protected static final String DEFAULT_LOGGER_CLASS = "com.mysql.jdbc.log.StandardLogger";	private final static int HISTOGRAM_BUCKETS = 20;	/** Logger instance name */	private static final String LOGGER_INSTANCE_NAME = "MySQL";	/**	 * Map mysql transaction isolation level name to	 * java.sql.Connection.TRANSACTION_XXX	 */	private static Map mapTransIsolationNameToValue = null;	/** Null logger shared by all connections at startup */	private static final Log NULL_LOGGER = new NullLogger(LOGGER_INSTANCE_NAME);	private static Map roundRobinStatsMap;	private static final Map serverCollationByUrl = new HashMap();	private static final Map serverConfigByUrl = new HashMap();	private static Timer cancelTimer;	static {		mapTransIsolationNameToValue = new HashMap(8);		mapTransIsolationNameToValue.put("READ-UNCOMMITED", new Integer(				TRANSACTION_READ_UNCOMMITTED));		mapTransIsolationNameToValue.put("READ-UNCOMMITTED", new Integer(				TRANSACTION_READ_UNCOMMITTED));		mapTransIsolationNameToValue.put("READ-COMMITTED", new Integer(				TRANSACTION_READ_COMMITTED));		mapTransIsolationNameToValue.put("REPEATABLE-READ", new Integer(				TRANSACTION_REPEATABLE_READ));		mapTransIsolationNameToValue.put("SERIALIZABLE", new Integer(				TRANSACTION_SERIALIZABLE));				boolean createdNamedTimer = false;				// Use reflection magic to try this on JDK's 1.5 and newer, fallback to non-named		// timer on older VMs.		try {			Constructor ctr = Timer.class.getConstructor(new Class[] {String.class, Boolean.TYPE});						cancelTimer = (Timer)ctr.newInstance(new Object[] { "MySQL Statement Cancellation Timer", Boolean.TRUE});			createdNamedTimer = true;		} catch (Throwable t) {			createdNamedTimer = false;		}				if (!createdNamedTimer) {			cancelTimer = new Timer(true);		}	}	protected static SQLException appendMessageToException(SQLException sqlEx,			String messageToAppend) {		String origMessage = sqlEx.getMessage();		String sqlState = sqlEx.getSQLState();		int vendorErrorCode = sqlEx.getErrorCode();		StringBuffer messageBuf = new StringBuffer(origMessage.length()				+ messageToAppend.length());		messageBuf.append(origMessage);		messageBuf.append(messageToAppend);		SQLException sqlExceptionWithNewMessage = SQLError.createSQLException(messageBuf				.toString(), sqlState, vendorErrorCode);		//		// Try and maintain the original stack trace,		// only works on JDK-1.4 and newer		//		try {			// Have to do this with reflection, otherwise older JVMs croak			Method getStackTraceMethod = null;			Method setStackTraceMethod = null;			Object theStackTraceAsObject = null;			Class stackTraceElementClass = Class					.forName("java.lang.StackTraceElement");			Class stackTraceElementArrayClass = Array.newInstance(					stackTraceElementClass, new int[] { 0 }).getClass();			getStackTraceMethod = Throwable.class.getMethod("getStackTrace",					new Class[] {});			setStackTraceMethod = Throwable.class.getMethod("setStackTrace",					new Class[] { stackTraceElementArrayClass });			if (getStackTraceMethod != null && setStackTraceMethod != null) {				theStackTraceAsObject = getStackTraceMethod.invoke(sqlEx,						new Object[0]);				setStackTraceMethod.invoke(sqlExceptionWithNewMessage,						new Object[] { theStackTraceAsObject });			}		} catch (NoClassDefFoundError noClassDefFound) {		} catch (NoSuchMethodException noSuchMethodEx) {		} catch (Throwable catchAll) {		}		return sqlExceptionWithNewMessage;	}	protected static Timer getCancelTimer() {		return cancelTimer;	}	private static synchronized int getNextRoundRobinHostIndex(String url,			List hostList) {		if (roundRobinStatsMap == null) {			roundRobinStatsMap = new HashMap();		}		int[] index = (int[]) roundRobinStatsMap.get(url);		if (index == null) {			index = new int[1];			index[0] = -1;			roundRobinStatsMap.put(url, index);		}		index[0]++;		if (index[0] >= hostList.size()) {			index[0] = 0;		}		return index[0];	}	private static boolean nullSafeCompare(String s1, String s2) {		if (s1 == null && s2 == null) {			return true;		}		if (s1 == null && s2 != null) {			return false;		}		return s1.equals(s2);	}	/** Are we in autoCommit mode? */	private boolean autoCommit = true;	/** A map of SQL to parsed prepared statement parameters. */	private Map cachedPreparedStatementParams;	/**	 * For servers > 4.1.0, what character set is the metadata returned in?	 */	private String characterSetMetadata = null;	/**	 * The character set we want results and result metadata returned in (null ==	 * results in any charset, metadata in UTF-8).	 */	private String characterSetResultsOnServer = null;	/**	 * Holds cached mappings to charset converters to avoid static	 * synchronization and at the same time save memory (each charset converter	 * takes approx 65K of static data).	 */	private Map charsetConverterMap = new HashMap(CharsetMapping			.getNumberOfCharsetsConfigured());	/**	 * The mapping between MySQL charset names and the max number of chars in	 * them. Lazily instantiated via getMaxBytesPerChar().	 */	private Map charsetToNumBytesMap;	/** The point in time when this connection was created */	private long connectionCreationTimeMillis = 0;	/** ID used when profiling */	private long connectionId;	/** The database we're currently using (called Catalog in JDBC terms). */	private String database = null;	/** Internal DBMD to use for various database-version specific features */	private DatabaseMetaData dbmd = null;	private TimeZone defaultTimeZone;	/** The event sink to use for profiling */	private ProfileEventSink eventSink;	private boolean executingFailoverReconnect = false;	/** Are we failed-over to a non-master host */	private boolean failedOver = false;	/** Why was this connection implicitly closed, if known? (for diagnostics) */	private Throwable forceClosedReason;	/** Where was this connection implicitly closed? (for diagnostics) */	private Throwable forcedClosedLocation;	/** Does the server suuport isolation levels? */	private boolean hasIsolationLevels = false;	/** Does this version of MySQL support quoted identifiers? */	private boolean hasQuotedIdentifiers = false;	/** The hostname we're connected to */	private String host = null;	/** The list of host(s) to try and connect to */	private List hostList = null;	/** How many hosts are in the host list? */	private int hostListSize = 0;	/**	 * We need this 'bootstrapped', because 4.1 and newer will send fields back	 * with this even before we fill this dynamically from the server.	 */	private String[] indexToCharsetMapping = CharsetMapping.INDEX_TO_CHARSET;	/** The I/O abstraction interface (network conn to MySQL server */	private MysqlIO io = null;		private boolean isClientTzUTC = false;		/** Has this connection been closed? */	private boolean isClosed = true;	/** Is this connection associated with a global tx? */	private boolean isInGlobalTx = false;	/** Is this connection running inside a JDK-1.3 VM? */	private boolean isRunningOnJDK13 = false;	/** isolation level */	private int isolationLevel = java.sql.Connection.TRANSACTION_READ_COMMITTED;	private boolean isServerTzUTC = false;	/** When did the last query finish? */	private long lastQueryFinishedTime = 0;	/** The logger we're going to use */	private Log log = NULL_LOGGER;	/**	 * If gathering metrics, what was the execution time of the longest query so	 * far ?	 */	private long longestQueryTimeMs = 0;	/** Is the server configured to use lower-case table names only? */	private boolean lowerCaseTableNames = false;	/** When did the master fail? */	private long masterFailTimeMillis = 0L;	/**	 * The largest packet we can send (changed once we know what the server	 * supports, we get this at connection init).	 */	private int maxAllowedPacket = 65536;	private long maximumNumberTablesAccessed = 0;	/** Has the max-rows setting been changed from the default? */	private boolean maxRowsChanged = false;	/** When was the last time we reported metrics? */	private long metricsLastReportedMs;	private long minimumNumberTablesAccessed = Long.MAX_VALUE;	/** Mutex */	private final Object mutex = new Object();	/** The JDBC URL we're using */	private String myURL = null;	/** Does this connection need to be tested? */	private boolean needsPing = false;	private int netBufferLength = 16384;	private boolean noBackslashEscapes = false;	private long numberOfPreparedExecutes = 0;	private long numberOfPrepares = 0;	private long numberOfQueriesIssued = 0;	private long numberOfResultSetsCreated = 0;	private long[] numTablesMetricsHistBreakpoints;	private int[] numTablesMetricsHistCounts;	private long[] oldHistBreakpoints = null;	private int[] oldHistCounts = null;	/** A map of currently open statements */	private Map openStatements;	private LRUCache parsedCallableStatementCache;	private boolean parserKnowsUnicode = false;	/** The password we used */	private String password = null;	private long[] perfMetricsHistBreakpoints;	private int[] perfMetricsHistCounts;	/** Point of origin where this Connection was created */	private Throwable pointOfOrigin;	/** The port number we're connected to (defaults to 3306) */	private int port = 3306;	/**	 * Used only when testing failover functionality for regressions, causes the	 * failover code to not retry the master first	 */	private boolean preferSlaveDuringFailover = false;	/** Properties for this connection specified by user */	private Properties props = null;	/** Number of queries we've issued since the master failed */	private long queriesIssuedFailedOver = 0;	/** Should we retrieve 'info' messages from the server? */	private boolean readInfoMsg = false;	/** Are we in read-only mode? */	private boolean readOnly = false;		/** Cache of ResultSet metadata */	protected LRUCache resultSetMetadataCache;		/** The timezone of the server */	private TimeZone serverTimezoneTZ = null;	/** The map of server variables that we retrieve at connection init. */	private Map serverVariables = null;	private long shortestQueryTimeMs = Long.MAX_VALUE;	/** A map of statements that have had setMaxRows() called on them */	private Map statementsUsingMaxRows;	private double totalQueryTimeMs = 0;	/** Are transactions supported by the MySQL server we are connected to? */	private boolean transactionsSupported = false;	/**	 * The type map for UDTs (not implemented, but used by some third-party	 * vendors, most notably IBM WebSphere)	 */	private Map typeMap;	/** Has ANSI_QUOTES been enabled on the server? */	private boolean useAnsiQuotes = false;	/** The user we're connected as */	private String user = null;	/**	 * Should we use server-side prepared statements? (auto-detected, but can be	 * disabled by user)	 */	private boolean useServerPreparedStmts = false;		private LRUCache serverSideStatementCheckCache;	private LRUCache serverSideStatementCache;	private Calendar sessionCalendar;	private Calendar utcCalendar;		private String origHostToConnectTo;		private int origPortToConnectTo;	// we don't want to be able to publicly clone this...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -