亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pooledconnectionregressiontest.java

?? mysql jdbc驅動程序 mysql jdbc驅動程序 mysql jdbc驅動程序 mysql jdbc驅動程序
?? JAVA
字號:
/* Copyright (C) 2002-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as  published by the Free Software Foundation. There are special exceptions to the terms and conditions of the GPL  as it is applied to this software. View the full text of the  exception in file EXCEPTIONS-CONNECTOR-J in the directory of this  software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  */package testsuite.regression;import java.io.BufferedInputStream;import java.io.FileInputStream;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.SQLException;import javax.sql.ConnectionEvent;import javax.sql.ConnectionEventListener;import javax.sql.ConnectionPoolDataSource;import javax.sql.PooledConnection;import junit.framework.Test;import junit.framework.TestSuite;import testsuite.BaseTestCase;import com.mysql.jdbc.PacketTooBigException;import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper;import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;/** * Tests a PooledConnection implementation provided by a JDBC driver. Test case * provided by Johnny Macchione from bug database record BUG#884. According to * the JDBC 2.0 specification: *  * <p> * "Each call to PooledConnection.getConnection() must return a newly * constructed Connection object that exhibits the default Connection behavior. * Only the most recent Connection object produced from a particular * PooledConnection is open. An existing Connection object is automatically * closed, if the getConnection() method of its associated Pooled-Connection is * called again, before it has been explicitly closed by the application. This * gives the application server a way to ?take away? a Connection from the * application if it wishes, and give it out to someone else. This capability * will not likely be used frequently in practice." * </p> *  * <p> * "When the application calls Connection.close(), an event is triggered that * tells the connection pool it can recycle the physical database connection. In * other words, the event signals the connection pool that the PooledConnection * object which originally produced the Connection object generating the event * can be put back in the connection pool." * </p> *  * <p> * "A Connection-EventListener will also be notified when a fatal error occurs, * so that it can make a note not to put a bad PooledConnection object back in * the cache when the application finishes using it. When an error occurs, the * ConnectionEventListener is notified by the JDBC driver, just before the * driver throws an SQLException to the application to notify it of the same * error. Note that automatic closing of a Connection object as discussed in the * previous section does not generate a connection close event." * </p> * The JDBC 3.0 specification states the same in other words: *  * <p> * "The Connection.close method closes the logical handle, but the physical * connection is maintained. The connection pool manager is notified that the * underlying PooledConnection object is now available for reuse. If the * application attempts to reuse the logical handle, the Connection * implementation throws an SQLException." * </p> *  * <p> * "For a given PooledConnection object, only the most recently produced logical * Connection object will be valid. Any previously existing Connection object is * automatically closed when the associated PooledConnection.getConnection * method is called. Listeners (connection pool managers) are not notified in * this case. This gives the application server a way to take a connection away * from a client. This is an unlikely scenario but may be useful if the * application server is trying to force an orderly shutdown." * </p> *  * <p> * "A connection pool manager shuts down a physical connection by calling the * method PooledConnection.close. This method is typically called only in * certain circumstances: when the application server is undergoing an orderly * shutdown, when the connection cache is being reinitialized, or when the * application server receives an event indicating that an unrecoverable error * has occurred on the connection." * </p> * Even though the specification isn't clear about it, I think it is no use * generating a close event when calling the method PooledConnection.close(), * even if a logical Connection is open for this PooledConnection, bc the * PooledConnection will obviously not be returned to the pool. *  * @author fcr */public final class PooledConnectionRegressionTest extends BaseTestCase {	private ConnectionPoolDataSource cpds;	// Count nb of closeEvent.	private int closeEventCount;	// Count nb of connectionErrorEvent	private int connectionErrorEventCount;	/**	 * Creates a new instance of ProgressPooledConnectionTest	 * 	 * @param testname	 *            DOCUMENT ME!	 */	public PooledConnectionRegressionTest(String testname) {		super(testname);	}	/**	 * Set up test case before a test is run.	 * 	 * @throws Exception	 *             DOCUMENT ME!	 */	public void setUp() throws Exception {		super.setUp();		// Reset event count.		this.closeEventCount = 0;		this.connectionErrorEventCount = 0;		MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();		ds.setURL(BaseTestCase.dbUrl);		this.cpds = ds;	}	/**	 * Runs all test cases in this test suite	 * 	 * @param args	 */	public static void main(String[] args) {		junit.textui.TestRunner.run(PooledConnectionRegressionTest.class);	}	/**	 * DOCUMENT ME!	 * 	 * @return a test suite composed of this test case.	 */	public static Test suite() {		TestSuite suite = new TestSuite(PooledConnectionRegressionTest.class);		return suite;	}	/**	 * After the test is run.	 */	public void tearDown() {		this.cpds = null;	}	/**	 * Tests fix for BUG#7136 ... Statement.getConnection() returning physical	 * connection instead of logical connection.	 */	public void testBug7136() {		final ConnectionEventListener conListener = new ConnectionListener();		PooledConnection pc = null;		this.closeEventCount = 0;		try {			pc = this.cpds.getPooledConnection();			pc.addConnectionEventListener(conListener);			Connection conn = pc.getConnection();			Connection connFromStatement = conn.createStatement()					.getConnection();			// This should generate a close event.			connFromStatement.close();			assertEquals("One close event should've been registered", 1,					this.closeEventCount);			this.closeEventCount = 0;			conn = pc.getConnection();			Connection connFromPreparedStatement = conn.prepareStatement(					"SELECT 1").getConnection();			// This should generate a close event.			connFromPreparedStatement.close();			assertEquals("One close event should've been registered", 1,					this.closeEventCount);		} catch (SQLException ex) {			fail(ex.toString());		} finally {			if (pc != null) {				try {					pc.close();				} catch (SQLException ex) {					ex.printStackTrace();				}			}		}	}	/**	 * Test the nb of closeEvents generated when a Connection is reclaimed. No	 * event should be generated in that case.	 */	public void testConnectionReclaim() {		final ConnectionEventListener conListener = new ConnectionListener();		PooledConnection pc = null;		final int NB_TESTS = 5;		try {			pc = this.cpds.getPooledConnection();			pc.addConnectionEventListener(conListener);			for (int i = 0; i < NB_TESTS; i++) {				Connection conn = pc.getConnection();				try {					// Try to reclaim connection.					System.out.println("Before connection reclaim.");					conn = pc.getConnection();					System.out.println("After connection reclaim.");				} finally {					if (conn != null) {						System.out.println("Before connection.close().");						// This should generate a close event.						conn.close();						System.out.println("After connection.close().");					}				}			}		} catch (SQLException ex) {			ex.printStackTrace();			fail(ex.toString());		} finally {			if (pc != null) {				try {					System.out.println("Before pooledConnection.close().");					// This should not generate a close event.					pc.close();					System.out.println("After pooledConnection.close().");				} catch (SQLException ex) {					ex.printStackTrace();					fail(ex.toString());				}			}		}		assertEquals("Wrong nb of CloseEvents: ", NB_TESTS,				this.closeEventCount);	}	/**	 * Tests that PacketTooLargeException doesn't clober the connection.	 * 	 * @throws Exception	 *             if the test fails.	 */	public void testPacketTooLargeException() throws Exception {		final ConnectionEventListener conListener = new ConnectionListener();		PooledConnection pc = null;		pc = this.cpds.getPooledConnection();		pc.addConnectionEventListener(conListener);		try {			this.stmt.executeUpdate("DROP TABLE IF EXISTS testPacketTooLarge");			this.stmt					.executeUpdate("CREATE TABLE testPacketTooLarge(field1 LONGBLOB)");			Connection connFromPool = pc.getConnection();			PreparedStatement pstmtFromPool = ((ConnectionWrapper) connFromPool)					.clientPrepare("INSERT INTO testPacketTooLarge VALUES (?)");			this.rs = this.stmt					.executeQuery("SHOW VARIABLES LIKE 'max_allowed_packet'");			this.rs.next();			int maxAllowedPacket = this.rs.getInt(2);			int numChars = (int) (maxAllowedPacket * 1.2);			pstmtFromPool.setBinaryStream(1, new BufferedInputStream(					new FileInputStream(newTempBinaryFile(							"testPacketTooLargeException", numChars))),					numChars);			try {				pstmtFromPool.executeUpdate();				fail("Expecting PacketTooLargeException");			} catch (PacketTooBigException ptbe) {				// We're expecting this one...			}			// This should still work okay, even though the last query on the			// same			// connection didn't...			connFromPool.createStatement().executeQuery("SELECT 1");			assertTrue(this.connectionErrorEventCount == 0);			assertTrue(this.closeEventCount == 0);		} finally {			this.stmt.executeUpdate("DROP TABLE IF EXISTS testPacketTooLarge");		}	}	/**	 * Test the nb of closeEvents generated by a PooledConnection. A	 * JDBC-compliant driver should only generate 1 closeEvent each time	 * connection.close() is called.	 */	public void testCloseEvent() {		final ConnectionEventListener conListener = new ConnectionListener();		PooledConnection pc = null;		final int NB_TESTS = 5;		try {			pc = this.cpds.getPooledConnection();			pc.addConnectionEventListener(conListener);			for (int i = 0; i < NB_TESTS; i++) {				Connection pConn = pc.getConnection();				System.out.println("Before connection.close().");				// This should generate a close event.				pConn.close();				System.out.println("After connection.close().");			}		} catch (SQLException ex) {			fail(ex.toString());		} finally {			if (pc != null) {				try {					System.out.println("Before pooledConnection.close().");					// This should not generate a close event.					pc.close();					System.out.println("After pooledConnection.close().");				} catch (SQLException ex) {					ex.printStackTrace();				}			}		}		assertEquals("Wrong nb of CloseEvents: ", NB_TESTS,				this.closeEventCount);	}	/**	 * Listener for PooledConnection events.	 */	private final class ConnectionListener implements ConnectionEventListener {		/** */		public void connectionClosed(ConnectionEvent event) {			PooledConnectionRegressionTest.this.closeEventCount++;			System.out					.println(PooledConnectionRegressionTest.this.closeEventCount							+ " - Connection closed.");		}		/** */		public void connectionErrorOccurred(ConnectionEvent event) {			PooledConnectionRegressionTest.this.connectionErrorEventCount++;			System.out.println("Connection error: " + event.getSQLException());		}	}}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩久久久一区| 精品国产1区2区3区| 亚洲免费观看在线视频| 国产成人亚洲综合a∨婷婷 | 另类小说欧美激情| 91麻豆精品国产91久久久资源速度| 亚洲欧美另类久久久精品2019| 国产成人啪午夜精品网站男同| 精品国产一区二区三区四区四 | 图片区日韩欧美亚洲| 欧洲亚洲精品在线| 亚洲精品免费在线| 91久久精品一区二区三区| 欧美激情在线看| 成人免费毛片高清视频| 国产精品免费视频网站| 99视频精品在线| 综合色天天鬼久久鬼色| 91免费观看国产| 亚洲色图制服诱惑 | 最新国产の精品合集bt伙计| 成人美女视频在线看| 中文字幕乱码亚洲精品一区 | 精品影院一区二区久久久| 欧美videos中文字幕| 国产一区二区视频在线播放| 国产资源在线一区| 国产日韩在线不卡| a级精品国产片在线观看| 亚洲人午夜精品天堂一二香蕉| 91免费在线看| 午夜欧美视频在线观看| 欧美一区国产二区| 国产综合一区二区| 中文字幕av一区 二区| 91香蕉国产在线观看软件| 一区二区高清免费观看影视大全| 欧美三级一区二区| 卡一卡二国产精品| 国产日韩欧美精品综合| 99国内精品久久| 亚洲成人免费视频| 精品日韩欧美一区二区| 国产69精品久久久久777| 亚洲欧美视频在线观看视频| 欧美人伦禁忌dvd放荡欲情| 老司机免费视频一区二区| 国产视频在线观看一区二区三区 | 麻豆国产一区二区| 国产精品污www在线观看| 色av综合在线| 蜜桃精品在线观看| 亚洲国产精品成人综合| 欧美在线观看禁18| 久久精品国产77777蜜臀| 中文字幕av一区二区三区高| 欧美日韩国产大片| 国产高清一区日本| 亚洲成人综合视频| wwwwww.欧美系列| 色婷婷久久久综合中文字幕| 日本成人在线电影网| 欧美国产激情一区二区三区蜜月 | 成人一级片在线观看| 亚洲动漫第一页| 久久理论电影网| 欧美三区免费完整视频在线观看| 蜜桃av噜噜一区| 自拍偷拍国产精品| 亚洲精品在线观看视频| 色综合久久综合网欧美综合网| 蜜桃av一区二区| 亚洲激情男女视频| 久久一日本道色综合| 欧美视频精品在线观看| 国产精品中文字幕欧美| 亚洲国产裸拍裸体视频在线观看乱了| 26uuu亚洲| 欧美日韩国产精品成人| 9色porny自拍视频一区二区| 日本vs亚洲vs韩国一区三区二区| 国产精品久久久久影院| 日韩免费视频一区| 91国偷自产一区二区三区观看| 国产一区二区三区免费在线观看| 亚洲一区二区视频在线| 国产欧美精品一区二区三区四区| 欧美女孩性生活视频| 99riav一区二区三区| 久久精品免费观看| 亚洲成人动漫一区| 国产精品成人免费| 精品伊人久久久久7777人| 亚洲综合色区另类av| 亚洲国产精品成人综合| 日韩欧美一级二级三级久久久| 色国产综合视频| 成人激情免费网站| 久久99精品国产麻豆婷婷 | 亚洲综合丝袜美腿| 中文字幕在线不卡视频| 久久亚洲一级片| 91精品国模一区二区三区| 91免费视频大全| 丁香婷婷综合激情五月色| 久久99久久精品欧美| 同产精品九九九| 亚洲一卡二卡三卡四卡无卡久久| 自拍av一区二区三区| 国产农村妇女精品| 欧美不卡视频一区| 51午夜精品国产| 欧美午夜电影网| 91丨九色丨蝌蚪丨老版| 高清久久久久久| 国产一区二区电影| 精品中文字幕一区二区小辣椒| 亚洲午夜久久久久中文字幕久| 亚洲欧美乱综合| 国产精品看片你懂得| 久久九九影视网| 久久精品人人做人人综合| 欧美成人乱码一区二区三区| 欧美精品久久一区二区三区 | 国产成人夜色高潮福利影视| 精东粉嫩av免费一区二区三区| 亚洲电影视频在线| 亚洲国产精品一区二区尤物区| 亚洲午夜在线电影| 亚洲综合在线五月| 亚洲一区二区黄色| 一区二区三区精品视频| 亚洲激情自拍偷拍| 一个色妞综合视频在线观看| 亚洲欧美日韩在线不卡| 日韩久久一区二区| 亚洲日本在线天堂| 亚洲日本va午夜在线影院| 日韩一区中文字幕| 亚洲人一二三区| 亚洲最大成人网4388xx| 亚洲大型综合色站| 日日骚欧美日韩| 日本不卡不码高清免费观看| 麻豆国产欧美一区二区三区| 极品尤物av久久免费看| 韩国女主播一区| 国产精品一区三区| 粉嫩aⅴ一区二区三区四区 | 色av综合在线| 欧美日韩成人综合在线一区二区| 在线不卡中文字幕播放| 精品欧美久久久| 欧美高清在线精品一区| 亚洲欧美视频在线观看| 亚洲成人av福利| 另类小说欧美激情| 国产精品18久久久久久久网站| 精品一区二区三区免费播放| 国产精品综合在线视频| 成人91在线观看| 亚洲免费在线视频一区 二区| 一区二区三区四区高清精品免费观看| 亚洲资源在线观看| 日韩电影在线免费看| 久久66热偷产精品| 高清beeg欧美| 日本精品视频一区二区三区| 欧美三级电影网站| 日韩欧美国产麻豆| 欧美精品一区二区蜜臀亚洲| 欧美激情在线看| 亚洲一区二区三区四区中文字幕| 天堂蜜桃一区二区三区| 国产在线播精品第三| av成人老司机| 日韩一本二本av| 国产精品视频你懂的| 亚洲国产一区视频| 国内一区二区在线| 97se亚洲国产综合在线| 9191成人精品久久| 欧美国产精品一区二区| 午夜久久久影院| 国产 欧美在线| 欧美妇女性影城| 国产精品午夜在线观看| 亚洲国产精品久久一线不卡| 国产一区二区不卡| 欧美日韩免费视频| 国产亚洲1区2区3区| 亚洲国产视频在线| 国产成人在线观看| 欧美另类一区二区三区| 欧美国产日本韩| 免费成人在线播放| 一本色道久久综合亚洲91 | 久久婷婷久久一区二区三区| 亚洲精品国产a久久久久久| 久久精品国产99国产精品|