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

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

?? statementstest.java

?? 用于JAVA數(shù)據(jù)庫連接.解壓就可用,方便得很
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 Copyright (C) 2002-2007 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.simple.jdbc4;

import java.io.Reader;
import java.io.StringReader;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

import testsuite.BaseTestCase;

public class StatementsTest extends BaseTestCase {

	public StatementsTest(String name) {
		super(name);
	
	}

	/**
	 * Tests for ResultSet.getNCharacterStream()
	 * 
	 * @throws Exception
	 */
	public void testGetNCharacterSteram() throws Exception {
	    createTable("testGetNCharacterStream", "(c1 NATIONAL CHARACTER(10), c2 NATIONAL CHARACTER(10))");
	    this.stmt.executeUpdate("INSERT INTO testGetNCharacterStream (c1, c2) VALUES (_utf8 'aaa', _utf8 'bbb')");
	    this.rs = this.stmt.executeQuery("SELECT c1, c2 FROM testGetNCharacterStream");
	    this.rs.next();
	    char[] c1 = new char[3];
	    this.rs.getNCharacterStream(1).read(c1);
	    assertEquals("aaa", new String(c1));
	    char[] c2 = new char[3];
	    this.rs.getNCharacterStream("c2").read(c2);
	    assertEquals("bbb", new String(c2));
	    this.rs.close();
	}

	/**
	 * Tests for ResultSet.getNClob()
	 * 
	 * @throws Exception
	 */
	public void testGetNClob() throws Exception {
	    createTable("testGetNClob", "(c1 NATIONAL CHARACTER(10), c2 NATIONAL CHARACTER(10))");
	    this.stmt.executeUpdate("INSERT INTO testGetNClob (c1, c2) VALUES (_utf8 'aaa', _utf8 'bbb')");
	    this.rs = this.stmt.executeQuery("SELECT c1, c2 FROM testGetNClob");
	    this.rs.next();
	    char[] c1 = new char[3];
	    this.rs.getNClob(1).getCharacterStream().read(c1);
	    assertEquals("aaa", new String(c1));
	    char[] c2 = new char[3];
	    this.rs.getNClob("c2").getCharacterStream().read(c2);
	    assertEquals("bbb", new String(c2));
	    this.rs.close();
	    
	    // for isBinaryEncoded = true, using PreparedStatement
	    createTable("testGetNClob", "(c1 NATIONAL CHARACTER(10), c2 NATIONAL CHARACTER(10))");
	    this.stmt.executeUpdate("INSERT INTO testGetNClob (c1, c2) VALUES (_utf8 'aaa', _utf8 'bbb')");
	    this.pstmt = this.conn.prepareStatement("SELECT c1, c2 FROM testGetNClob");
	    this.rs = this.pstmt.executeQuery();
	    this.rs.next();
	    c1 = new char[3];
	    this.rs.getNClob(1).getCharacterStream().read(c1);
	    assertEquals("aaa", new String(c1));
	    c2 = new char[3];
	    this.rs.getNClob("c2").getCharacterStream().read(c2);
	    assertEquals("bbb", new String(c2));
	    this.rs.close();
	}

	/**
	 * Tests for ResultSet.getNString()
	 * 
	 * @throws Exception
	 */
	public void testGetNString() throws Exception {
	    createTable("testGetNString", "(c1 NATIONAL CHARACTER(10), c2 NATIONAL CHARACTER(10))");
	    this.stmt.executeUpdate("INSERT INTO testGetNString (c1, c2) VALUES (_utf8 'aaa', _utf8 'bbb')");
	    this.rs = this.stmt.executeQuery("SELECT c1, c2 FROM testGetNString");
	    this.rs.next();
	    assertEquals("aaa", this.rs.getNString(1));
	    assertEquals("bbb", this.rs.getNString("c2"));
	    this.rs.close();
	}

	/**
	 * Tests for PreparedStatement.setNCharacterSteam()
	 * 
	 * @throws Exception
	 */
	public void testSetNCharacterStream() throws Exception {
	    // suppose sql_mode don't include "NO_BACKSLASH_ESCAPES"
	    
	    createTable("testSetNCharacterStream", "(c1 NATIONAL CHARACTER(10), c2 NATIONAL CHARACTER(10), " +
	            "c3 NATIONAL CHARACTER(10))");
	    Properties props1 = new Properties();
	    props1.put("useServerPrepStmts", "false"); // use client-side prepared statement
	    props1.put("useUnicode", "true");
	    props1.put("characterEncoding", "latin1"); // ensure charset isn't utf8 here
	    Connection conn1 = getConnectionWithProps(props1);
	    com.mysql.jdbc.PreparedStatement pstmt1 = (com.mysql.jdbc.PreparedStatement)
	        conn1.prepareStatement("INSERT INTO testSetNCharacterStream (c1, c2, c3) VALUES (?, ?, ?)");
	    pstmt1.setNCharacterStream(1, null, 0);
	    pstmt1.setNCharacterStream(2, new StringReader("aaa"), 3);
	    pstmt1.setNCharacterStream(3, new StringReader("\'aaa\'"), 5);
	    pstmt1.execute();
	    ResultSet rs1 = this.stmt.executeQuery("SELECT c1, c2, c3 FROM testSetNCharacterStream");
	    rs1.next();
	    assertEquals(null, rs1.getString(1));
	    assertEquals("aaa", rs1.getString(2));
	    assertEquals("\'aaa\'", rs1.getString(3));
	    rs1.close();
	    pstmt1.close();
	    conn1.close();
	    
	    createTable("testSetNCharacterStream", "(c1 NATIONAL CHARACTER(10), c2 NATIONAL CHARACTER(10), " +
	    "c3 NATIONAL CHARACTER(10))");
	    Properties props2 = new Properties();
	    props2.put("useServerPrepStmts", "false"); // use client-side prepared statement
	    props2.put("useUnicode", "true");
	    props2.put("characterEncoding", "UTF-8"); // ensure charset is utf8 here
	    Connection conn2 = getConnectionWithProps(props2);
	    com.mysql.jdbc.PreparedStatement pstmt2 = (com.mysql.jdbc.PreparedStatement)
	        conn2.prepareStatement("INSERT INTO testSetNCharacterStream (c1, c2, c3) VALUES (?, ?, ?)");
	    pstmt2.setNCharacterStream(1, null, 0);
	    pstmt2.setNCharacterStream(2, new StringReader("aaa"), 3);
	    pstmt2.setNCharacterStream(3, new StringReader("\'aaa\'"), 5);
	    pstmt2.execute();
	    ResultSet rs2 = this.stmt.executeQuery("SELECT c1, c2, c3 FROM testSetNCharacterStream");
	    rs2.next();
	    assertEquals(null, rs2.getString(1));
	    assertEquals("aaa", rs2.getString(2));
	    assertEquals("\'aaa\'", rs2.getString(3));
	    rs2.close();
	    pstmt2.close();
	    conn2.close();
	}

	/**
	 * Tests for ServerPreparedStatement.setNCharacterSteam()
	 * 
	 * @throws Exception
	 */
	public void testSetNCharacterStreamServer() throws Exception {
	    createTable("testSetNCharacterStreamServer", "(c1 NATIONAL CHARACTER(10))");
	    Properties props1 = new Properties();
	    props1.put("useServerPrepStmts", "true"); // use server-side prepared statement
	    props1.put("useUnicode", "true");
	    props1.put("characterEncoding", "latin1"); // ensure charset isn't utf8 here
	    Connection conn1 = getConnectionWithProps(props1);
	    PreparedStatement pstmt1 =  conn1.prepareStatement("INSERT INTO testSetNCharacterStreamServer (c1) VALUES (?)");
	    try {
	        pstmt1.setNCharacterStream(1, new StringReader("aaa"), 3);
	        fail();
	    } catch (SQLException e) {
	        // ok
	        assertEquals("Can not call setNCharacterStream() when connection character set isn't UTF-8",
	            e.getMessage());  
	    }
	    pstmt1.close();
	    conn1.close();
	    
	    createTable("testSetNCharacterStreamServer", "(c1 LONGTEXT charset utf8)");
	    Properties props2 = new Properties();
	    props2.put("useServerPrepStmts", "true"); // use server-side prepared statement
	    props2.put("useUnicode", "true");
	    props2.put("characterEncoding", "UTF-8"); // ensure charset is utf8 here
	    Connection conn2 = getConnectionWithProps(props2);
	    PreparedStatement pstmt2 = 
	        conn2.prepareStatement("INSERT INTO testSetNCharacterStreamServer (c1) VALUES (?)");
	    pstmt2.setNCharacterStream(1, new StringReader(
	            new String(new char[81921])), 81921); // 10 Full Long Data Packet's chars + 1 char
	    pstmt2.execute();
	    ResultSet rs2 = this.stmt.executeQuery("SELECT c1 FROM testSetNCharacterStreamServer");
	    rs2.next();
	    assertEquals(new String(new char[81921]), rs2.getString(1));
	    rs2.close();
	    pstmt2.close();
	    conn2.close();
	}

	/**
	 * Tests for PreparedStatement.setNClob()
	 * 
	 * @throws Exception
	 */
	public void testSetNClob() throws Exception {
	    // suppose sql_mode don't include "NO_BACKSLASH_ESCAPES"
	    
	    createTable("testSetNClob", "(c1 NATIONAL CHARACTER(10), c2 NATIONAL CHARACTER(10), " +
	            "c3 NATIONAL CHARACTER(10))");
	    Properties props1 = new Properties();
	    props1.put("useServerPrepStmts", "false"); // use client-side prepared statement
	    props1.put("useUnicode", "true");
	    props1.put("characterEncoding", "latin1"); // ensure charset isn't utf8 here
	    Connection conn1 = getConnectionWithProps(props1);
	    PreparedStatement pstmt1 = 
	        conn1.prepareStatement("INSERT INTO testSetNClob (c1, c2, c3) VALUES (?, ?, ?)");
	    pstmt1.setNClob(1, (NClob)null);
	    NClob nclob2 = conn1.createNClob();
	    nclob2.setString(1, "aaa");
	    pstmt1.setNClob(2, nclob2);                   // for setNClob(int, NClob)
	    Reader reader3 = new StringReader("\'aaa\'");
	    pstmt1.setNClob(3, reader3, 5);               // for setNClob(int, Reader, long)
	    pstmt1.execute();
	    ResultSet rs1 = this.stmt.executeQuery("SELECT c1, c2, c3 FROM testSetNClob");
	    rs1.next();
	    assertEquals(null, rs1.getString(1));
	    assertEquals("aaa", rs1.getString(2));
	    assertEquals("\'aaa\'", rs1.getString(3));
	    rs1.close();
	    pstmt1.close();
	    conn1.close();
	    
	    createTable("testSetNClob", "(c1 NATIONAL CHARACTER(10), c2 NATIONAL CHARACTER(10), " +
	    "c3 NATIONAL CHARACTER(10))");
	    Properties props2 = new Properties();
	    props2.put("useServerPrepStmts", "false"); // use client-side prepared statement
	    props2.put("useUnicode", "true");
	    props2.put("characterEncoding", "UTF-8"); // ensure charset is utf8 here
	    Connection conn2 = getConnectionWithProps(props2);
	    PreparedStatement pstmt2 = 
	        conn2.prepareStatement("INSERT INTO testSetNClob (c1, c2, c3) VALUES (?, ?, ?)");
	    pstmt2.setNClob(1, (NClob)null);
	    nclob2 = conn2.createNClob();
	    nclob2.setString(1, "aaa");
	    pstmt2.setNClob(2, nclob2);             // for setNClob(int, NClob)
	    reader3 = new StringReader("\'aaa\'");
	    pstmt2.setNClob(3, reader3, 5);         // for setNClob(int, Reader, long)
	    pstmt2.execute();
	    ResultSet rs2 = this.stmt.executeQuery("SELECT c1, c2, c3 FROM testSetNClob");
	    rs2.next();
	    assertEquals(null, rs2.getString(1));
	    assertEquals("aaa", rs2.getString(2));
	    assertEquals("\'aaa\'", rs2.getString(3));
	    rs2.close();
	    pstmt2.close();
	    conn2.close();
	}

	/**
	 * Tests for ServerPreparedStatement.setNClob()
	 * 
	 * @throws Exception
	 */
	public void testSetNClobServer() throws Exception {
	    createTable("testSetNClobServer", "(c1 NATIONAL CHARACTER(10), c2 NATIONAL CHARACTER(10))");
	    Properties props1 = new Properties();
	    props1.put("useServerPrepStmts", "true"); // use server-side prepared statement
	    props1.put("useUnicode", "true");
	    props1.put("characterEncoding", "latin1"); // ensure charset isn't utf8 here
	    Connection conn1 = getConnectionWithProps(props1);
	    PreparedStatement pstmt1 = 
	        conn1.prepareStatement("INSERT INTO testSetNClobServer (c1, c2) VALUES (?, ?)");
	    NClob nclob1 = conn1.createNClob();
	    nclob1.setString(1, "aaa");
	    Reader reader2 = new StringReader("aaa");
	    try {
	        pstmt1.setNClob(1, nclob1);
	        fail();
	    } catch (SQLException e) {
	        // ok
	        assertEquals("Can not call setNClob() when connection character set isn't UTF-8",
	            e.getMessage());  
	    }
	    try {
	        pstmt1.setNClob(2, reader2, 3);
	        fail();
	    } catch (SQLException e) {
	        // ok
	        assertEquals("Can not call setNClob() when connection character set isn't UTF-8",
	            e.getMessage());  
	    }
	    pstmt1.close();
	    conn1.close();
	    
	    createTable("testSetNClobServer", "(c1 NATIONAL CHARACTER(10), c2 LONGTEXT charset utf8)");
	    Properties props2 = new Properties();
	    props2.put("useServerPrepStmts", "true"); // use server-side prepared statement
	    props2.put("useUnicode", "true");
	    props2.put("characterEncoding", "UTF-8"); // ensure charset is utf8 here
	    Connection conn2 = getConnectionWithProps(props2);
	    PreparedStatement pstmt2 = 
	        conn2.prepareStatement("INSERT INTO testSetNClobServer (c1, c2) VALUES (?, ?)");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区五区| 国产在线视频精品一区| 免费高清视频精品| 成人精品免费看| 欧美一区二区三区视频在线| 日韩伦理免费电影| 国产一级精品在线| 91精品视频网| 一个色在线综合| 成人做爰69片免费看网站| 日韩一区二区麻豆国产| 亚洲在线视频网站| 91丝袜美腿高跟国产极品老师| 亚洲精品在线电影| 麻豆国产精品视频| 91精品免费在线| 亚洲成a人片在线观看中文| 色婷婷香蕉在线一区二区| 国产精品免费网站在线观看| 国产一二精品视频| xf在线a精品一区二区视频网站| 亚洲成人av免费| 欧美色图第一页| 亚洲美女在线一区| 91亚洲国产成人精品一区二三 | 国产高清久久久久| 精品1区2区在线观看| 久久99国产精品麻豆| 精品国产欧美一区二区| 国产在线视频一区二区三区| 久久综合色之久久综合| 捆绑紧缚一区二区三区视频| 欧美一区二区三区四区在线观看| 日本不卡一二三区黄网| 欧美一级淫片007| 免费高清视频精品| 欧美成va人片在线观看| 国内欧美视频一区二区| 久久久av毛片精品| 不卡的av电影| 亚洲国产一区二区三区| 制服.丝袜.亚洲.中文.综合| 麻豆成人91精品二区三区| 精品入口麻豆88视频| 国产在线国偷精品产拍免费yy| 26uuu亚洲| av成人免费在线观看| 一区二区欧美在线观看| 777色狠狠一区二区三区| 毛片基地黄久久久久久天堂| 久久免费的精品国产v∧| 国产精品一二三区| 亚洲精品国产高清久久伦理二区| 欧美亚洲禁片免费| 久久国产生活片100| 亚洲国产精品成人综合 | 国产精品自在在线| 国产精品国产精品国产专区不片| 色av成人天堂桃色av| 日本成人在线看| 亚洲国产精品国自产拍av| 91国模大尺度私拍在线视频| 欧美a级一区二区| 中文成人av在线| 精品视频在线免费| 国产成人日日夜夜| 亚洲成人黄色影院| 国产欧美日韩在线| 欧美日韩视频在线第一区 | 丝袜诱惑制服诱惑色一区在线观看| 日韩精品一区二区在线| 91丨九色丨国产丨porny| 日本不卡在线视频| 亚洲免费av高清| 久久午夜色播影院免费高清| 在线观看不卡一区| 国产成人无遮挡在线视频| 亚洲成人你懂的| 国产欧美日韩不卡免费| 欧美片在线播放| 91免费国产在线| 国产一区二区剧情av在线| 亚洲1区2区3区视频| 日本一区二区三区高清不卡| 91超碰这里只有精品国产| 99久久免费视频.com| 精品亚洲欧美一区| 婷婷成人激情在线网| 中文字幕不卡在线播放| 91精品国产黑色紧身裤美女| 91热门视频在线观看| 国产综合一区二区| 麻豆精品蜜桃视频网站| 五月天激情综合网| 亚洲靠逼com| 中文字幕一区二| 国产区在线观看成人精品| 欧美电视剧免费观看| 欧美夫妻性生活| 欧美三级三级三级爽爽爽| 波多野结衣中文字幕一区| 国产精品影音先锋| 精品在线观看免费| 成人性视频网站| 麻豆精品久久精品色综合| 五月天激情小说综合| 亚洲国产一区二区三区| 亚洲国产成人tv| 亚洲在线视频网站| 午夜影院久久久| 天天综合色天天| 日本成人超碰在线观看| 日本怡春院一区二区| 男女性色大片免费观看一区二区 | 久久成人18免费观看| 人人狠狠综合久久亚洲| 日本亚洲最大的色成网站www| 亚洲国产精品久久一线不卡| 亚洲成人综合网站| 日日骚欧美日韩| 免费高清在线一区| 国产美女娇喘av呻吟久久| 国产成人免费视频网站 | 亚洲国产精品黑人久久久| 国产精品天美传媒沈樵| 国产精品成人午夜| 亚洲视频免费在线| 五月综合激情日本mⅴ| 蜜臀av国产精品久久久久| 国产毛片精品视频| 99精品国产99久久久久久白柏 | 7777女厕盗摄久久久| 日韩欧美一区二区三区在线| 久久久久久麻豆| 中文子幕无线码一区tr| 国产精品二区一区二区aⅴ污介绍| 亚洲九九爱视频| 日韩电影在线观看电影| 国产精品综合久久| 日本精品免费观看高清观看| 欧美久久一区二区| 久久天天做天天爱综合色| 亚洲欧洲一区二区在线播放| 亚洲国产日韩一级| 国产一区在线不卡| 色综合一个色综合| 欧美α欧美αv大片| 国产精品美女久久久久久| 午夜激情一区二区| 国产99久久久国产精品潘金| 欧美做爰猛烈大尺度电影无法无天| 91精品蜜臀在线一区尤物| 国产精品久久久久aaaa樱花| 日韩精品福利网| 成人黄色av电影| 日韩欧美一级二级三级| 国产精品久久久久久久久图文区| 亚洲国产成人高清精品| 91玉足脚交白嫩脚丫在线播放| 欧美天天综合网| 国产欧美久久久精品影院| 五月婷婷久久综合| 99久久99久久精品国产片果冻| 欧美一级电影网站| 亚洲精品午夜久久久| 国产美女一区二区三区| 欧美日韩免费不卡视频一区二区三区| 欧美mv和日韩mv国产网站| 亚洲综合另类小说| 成人亚洲一区二区一| 日韩欧美一区电影| 午夜欧美在线一二页| 日本电影亚洲天堂一区| 国产午夜亚洲精品不卡| 麻豆精品视频在线观看免费| 欧美午夜精品一区二区三区| 国产精品欧美久久久久无广告| 日本特黄久久久高潮| 欧美三电影在线| 亚洲免费观看高清| 91网站在线观看视频| 国产午夜精品理论片a级大结局 | 亚洲人午夜精品天堂一二香蕉| 国产呦萝稀缺另类资源| 日韩精品中午字幕| 日本午夜精品视频在线观看| 欧美日韩一区二区三区四区| 亚洲视频1区2区| av一区二区三区黑人| 国产精品午夜在线| 粉嫩嫩av羞羞动漫久久久| 久久精品视频一区二区三区| 裸体一区二区三区| 日韩三级av在线播放| 日韩电影在线一区二区三区| 欧美一区永久视频免费观看| 首页国产欧美久久| 日韩一区二区高清| 日本成人在线网站| 欧美xxxx在线观看|