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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? pooledconnectionregressiontest.java

?? 用于JAVA數(shù)據(jù)庫(kù)連接.解壓就可用,方便得很
?? JAVA
字號(hào):
/* 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());		}	}}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品一区二区www在线| 国产欧美精品国产国产专区 | 91丨porny丨最新| 精品91自产拍在线观看一区| 亚洲另类色综合网站| av电影天堂一区二区在线| 国产人成一区二区三区影院| 欧美日韩和欧美的一区二区| 亚洲人成在线播放网站岛国| av激情成人网| 国产毛片一区二区| 国产日产亚洲精品系列| 欧美另类videos死尸| 日本在线不卡视频| 欧美一二区视频| 精品一区二区在线免费观看| 欧美哺乳videos| av高清久久久| 国产v日产∨综合v精品视频| 国产精品久久久久四虎| 91免费在线看| 成人午夜看片网址| 亚洲成在人线在线播放| 久久午夜电影网| 成人午夜av影视| 精品亚洲porn| 久久99国产乱子伦精品免费| 日韩国产精品久久| 亚洲国产成人porn| 亚洲va欧美va国产va天堂影院| 一区二区三区在线视频播放| 欧美一级片在线观看| 国产美女精品一区二区三区| 精品一区精品二区高清| 国产一区二区三区四| 激情欧美一区二区三区在线观看| 亚洲色图在线看| 日韩精品中文字幕在线不卡尤物| 成人av片在线观看| 日本不卡一区二区三区高清视频| 日韩精品一区二区三区四区| 日韩精品中文字幕一区二区三区| 精品久久人人做人人爽| 久久久久国产免费免费| 欧美日韩亚洲高清一区二区| 国产一区欧美日韩| 国产一区二区三区黄视频 | 色系网站成人免费| 日本成人中文字幕| 美女在线一区二区| 夜夜嗨av一区二区三区中文字幕 | 宅男噜噜噜66一区二区66| eeuss鲁片一区二区三区 | 国产在线视频一区二区| 国产精品主播直播| 日韩av一级电影| 美女高潮久久久| 国产精一区二区三区| 成人美女在线观看| 欧美午夜电影在线播放| 高清成人在线观看| 色婷婷狠狠综合| 欧美一区二区三区在线观看| 精品免费国产一区二区三区四区| 久久久www免费人成精品| 18欧美亚洲精品| 国产精品丝袜一区| 国产无人区一区二区三区| 日韩欧美国产一二三区| 日本一区二区在线不卡| 亚洲人妖av一区二区| 奇米影视一区二区三区| 粉嫩av一区二区三区粉嫩| 欧美午夜电影一区| 国产亚洲精品超碰| 一区二区三区电影在线播| 激情深爱一区二区| 欧美最猛性xxxxx直播| 99视频精品在线| 欧美日韩激情一区二区| 国产夜色精品一区二区av| 一区二区三区.www| 国产美女视频91| 欧美最猛性xxxxx直播| 亚洲精品一区二区三区在线观看| 国产精品短视频| 舔着乳尖日韩一区| 日精品一区二区| 免费的国产精品| 91年精品国产| 国产亚洲欧美在线| 天堂蜜桃91精品| 欧美亚洲国产一区在线观看网站| 日韩精品一区二区三区视频| 亚洲精品中文在线观看| 国产裸体歌舞团一区二区| 欧美三电影在线| 国产精品传媒视频| 国产一区二区三区在线观看免费视频 | 91首页免费视频| 精品久久久久久久久久久久久久久久久| 国产精品乱码一区二三区小蝌蚪| 日韩av中文字幕一区二区三区 | 欧美日韩亚洲综合在线| 国产精品久久久久久久久免费相片| 蜜臀久久99精品久久久久久9| 色综合久久综合网97色综合| 久久久综合视频| 久久国内精品自在自线400部| 美女网站视频久久| 欧美性三三影院| 自拍偷拍国产亚洲| 成人动漫精品一区二区| 精品国产a毛片| 日韩成人精品在线观看| 欧美亚洲国产一区二区三区| 1区2区3区精品视频| www.日韩av| 中文av一区特黄| 国产91精品一区二区麻豆亚洲| 欧美成人免费网站| 久久国产精品无码网站| 欧美人xxxx| 亚洲第一福利视频在线| 在线观看亚洲一区| 一区二区三区国产| 91国产精品成人| 91精品婷婷国产综合久久竹菊| 亚洲免费在线观看| 色美美综合视频| 洋洋av久久久久久久一区| 色诱视频网站一区| 亚洲精品va在线观看| 欧美综合亚洲图片综合区| 亚洲精品免费在线观看| 91福利国产精品| 亚洲国产精品一区二区www在线| 在线中文字幕不卡| 午夜伦理一区二区| 欧美一卡二卡三卡四卡| 精品一区二区三区免费毛片爱| 欧美精品一区二区三区四区| 精品一区二区三区的国产在线播放| 精品久久一区二区| 丰满少妇久久久久久久| 国产精品久久久久久久浪潮网站| 99精品黄色片免费大全| 欧美不卡激情三级在线观看| 国产在线精品一区在线观看麻豆| 国产欧美日韩在线| 99re在线精品| 午夜精品久久久久久不卡8050| 日韩一级在线观看| 国产尤物一区二区| 亚洲天堂a在线| 欧美亚洲日本一区| 九色综合狠狠综合久久| 国产日韩av一区| 色欧美日韩亚洲| 蜜臀国产一区二区三区在线播放| 国产视频一区不卡| 91麻豆免费视频| 秋霞国产午夜精品免费视频 | 亚洲sss视频在线视频| 日韩免费在线观看| www..com久久爱| 午夜精品爽啪视频| 国产亚洲一二三区| 欧美综合亚洲图片综合区| 裸体在线国模精品偷拍| 国产精品国产三级国产普通话99| 欧美日韩在线电影| 国内成人精品2018免费看| 亚洲色图欧洲色图婷婷| 欧美一级在线观看| 99久久精品免费看国产免费软件| 亚洲午夜免费电影| 国产亚洲综合av| 欧美日韩高清一区二区| 国产成人自拍在线| 久久综合色婷婷| 91论坛在线播放| 久久99精品久久久久久| 亚洲综合一区在线| 欧美色偷偷大香| 国产成人免费在线视频| 亚洲福利一区二区| 国产精品久久久久永久免费观看 | 欧美日韩精品电影| 成人av在线资源| 久久福利资源站| 一个色妞综合视频在线观看| 久久久亚洲综合| 777奇米四色成人影色区| 99久久综合99久久综合网站| 九色综合狠狠综合久久| 亚洲成人黄色影院| 亚洲国产精品99久久久久久久久| 国产一区二区毛片| 日韩在线a电影|