當前位置: 首頁>>代碼示例>>Java>>正文


Java Connection.createNClob方法代碼示例

本文整理匯總了Java中java.sql.Connection.createNClob方法的典型用法代碼示例。如果您正苦於以下問題:Java Connection.createNClob方法的具體用法?Java Connection.createNClob怎麽用?Java Connection.createNClob使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.Connection的用法示例。


在下文中一共展示了Connection.createNClob方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testJdbc4LoadBalancing

import java.sql.Connection; //導入方法依賴的package包/類
public void testJdbc4LoadBalancing() throws Exception {
    Properties props = new Properties();
    props.setProperty("loadBalanceStrategy", CountingReBalanceStrategy.class.getName());
    props.setProperty("loadBalanceAutoCommitStatementThreshold", "3");

    String portNumber = new NonRegisteringDriver().parseURL(dbUrl, null).getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);

    if (portNumber == null) {
        portNumber = "3306";
    }

    Connection conn2 = this.getUnreliableLoadBalancedConnection(new String[] { "first", "second" }, props);
    try {
        conn2.createNClob();
    } catch (SQLException e) {
        fail("Unable to call Connection.createNClob() in load-balanced connection");
    }

}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:20,代碼來源:StatementsTest.java

示例2: testBug56122

import java.sql.Connection; //導入方法依賴的package包/類
/**
 * Tests fix for Bug#56122 - JDBC4 functionality failure when using replication connections.
 */
public void testBug56122() throws Exception {
    for (final Connection testConn : new Connection[] { this.conn, getFailoverConnection(), getLoadBalancedConnection(),
            getMasterSlaveReplicationConnection() }) {
        testConn.createClob();
        testConn.createBlob();
        testConn.createNClob();
        testConn.createSQLXML();
        testConn.isValid(12345);
        testConn.setClientInfo(new Properties());
        testConn.setClientInfo("NAME", "VALUE");
        testConn.getClientInfo();
        testConn.getClientInfo("CLIENT");
        assertThrows(SQLFeatureNotSupportedException.class, new Callable<Void>() {
            public Void call() throws Exception {
                testConn.createArrayOf("A_TYPE", null);
                return null;
            }
        });
        assertThrows(SQLFeatureNotSupportedException.class, new Callable<Void>() {
            public Void call() throws Exception {
                testConn.createStruct("A_TYPE", null);
                return null;
            }
        });
    }
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:30,代碼來源:ConnectionRegressionTest.java

示例3: testUpdateNClob

import java.sql.Connection; //導入方法依賴的package包/類
/**
 * Tests for ResultSet.updateNClob()
 * 
 * @throws Exception
 */
public void testUpdateNClob() throws Exception {
    createTable("testUpdateNChlob", "(c1 CHAR(10) PRIMARY KEY, c2 NATIONAL CHARACTER(10)) default character set sjis");
    Properties props1 = new Properties();
    props1.put("useServerPrepStmts", "true"); // use server-side prepared statement
    props1.put("characterEncoding", "UTF-8"); // ensure charset isn't utf8 here
    Connection conn1 = getConnectionWithProps(props1);
    PreparedStatement pstmt1 = conn1.prepareStatement("INSERT INTO testUpdateNChlob (c1, c2) VALUES (?, ?)");
    pstmt1.setString(1, "1");
    NClob nClob1 = conn1.createNClob();
    nClob1.setString(1, "aaa");
    pstmt1.setNClob(2, nClob1);
    pstmt1.execute();
    Statement stmt1 = conn1.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs1 = stmt1.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs1.next();
    NClob nClob2 = conn1.createNClob();
    nClob2.setString(1, "bbb");
    rs1.updateNClob("c2", nClob2);
    rs1.updateRow();
    rs1.moveToInsertRow();
    rs1.updateString("c1", "2");
    NClob nClob3 = conn1.createNClob();
    nClob3.setString(1, "ccc");
    rs1.updateNClob("c2", nClob3);
    rs1.insertRow();
    ResultSet rs2 = stmt1.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs2.next();
    assertEquals("1", rs2.getString("c1"));
    assertEquals("bbb", rs2.getNString("c2"));
    rs2.next();
    assertEquals("2", rs2.getString("c1"));
    assertEquals("ccc", rs2.getNString("c2"));
    pstmt1.close();
    stmt1.close();
    conn1.close();

    createTable("testUpdateNChlob", "(c1 CHAR(10) PRIMARY KEY, c2 CHAR(10)) default character set sjis"); // sjis field
    Properties props2 = new Properties();
    props2.put("useServerPrepStmts", "true"); // use server-side prepared statement
    props2.put("characterEncoding", "SJIS"); // ensure charset isn't utf8 here
    Connection conn2 = getConnectionWithProps(props2);
    PreparedStatement pstmt2 = conn2.prepareStatement("INSERT INTO testUpdateNChlob (c1, c2) VALUES (?, ?)");
    pstmt2.setString(1, "1");
    pstmt2.setString(2, "aaa");
    pstmt2.execute();
    Statement stmt2 = conn2.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs3 = stmt2.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs3.next();
    NClob nClob4 = conn2.createNClob();
    nClob4.setString(1, "bbb");
    try {
        rs3.updateNClob("c2", nClob4); // field's charset isn't utf8
        fail();
    } catch (SQLException ex) {
        assertEquals("Can not call updateNClob() when field's character set isn't UTF-8", ex.getMessage());
    }
    rs3.close();
    pstmt2.close();
    stmt2.close();
    conn2.close();
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:67,代碼來源:StatementsTest.java

示例4: executeOnConnection

import java.sql.Connection; //導入方法依賴的package包/類
@Override
public NClob executeOnConnection(Connection connection) throws SQLException {
	return connection.createNClob();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:ContextualLobCreator.java

示例5: createNClob

import java.sql.Connection; //導入方法依賴的package包/類
/**
 * {@link java.sql.Connection#createNClob()}のラッパー
 *
 * @param conn コネクション
 * @return NClobインタフェースを実裝しているオブジェクト
 *
 * @see java.sql.Connection#createNClob()
 */
public static NClob createNClob(final Connection conn) {
	try {
		return conn.createNClob();
	} catch (SQLException e) {
		throw new UroborosqlRuntimeException(e);
	}
}
 
開發者ID:future-architect,項目名稱:uroborosql,代碼行數:16,代碼來源:JdbcParameterFactory.java


注:本文中的java.sql.Connection.createNClob方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。