Java Code Examples for java.sql.Statement#setMaxFieldSize()
The following examples show how to use
java.sql.Statement#setMaxFieldSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractStatementAdapter.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 5 votes |
@Override public final void setMaxFieldSize(final int max) throws SQLException { if (getRoutedStatements().isEmpty()) { recordMethodInvocation(recordTargetClass, "setMaxFieldSize", new Class[] {int.class}, new Object[] {max}); return; } for (Statement each : getRoutedStatements()) { each.setMaxFieldSize(max); } }
Example 2
Source File: J2EEDataSourceTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** Create a statement with modified State. */ private Statement createFloatStatementForStateChecking( int[] StatementExpectedValues, Connection conn) throws SQLException { Statement s = internalCreateFloatStatementForStateChecking(conn); s.setCursorName("StokeNewington"); s.setFetchDirection(ResultSet.FETCH_REVERSE); s.setFetchSize(444); s.setMaxFieldSize(713); s.setMaxRows(19); // Create assertStatementState(null, StatementExpectedValues, s); return s; }
Example 3
Source File: maxfieldsize.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private static void testSort(Connection conn, Statement stmt) throws SQLException, java.io.UnsupportedEncodingException { PreparedStatement insertPStmt; // Load up a 2nd table using streams where appropriate stmt.execute("create table tab2("+ "c0 int, " + "c1 char(100) for bit data,"+ "c2 varchar(100) for bit data," + "c3 long varchar for bit data,"+ "c4 char(100),"+ "c5 varchar(100),"+ "c6 long varchar)"); // Populate the table insertPStmt = conn.prepareStatement( "insert into tab2 values (?, ?, ?, ?, ?, ?, ?)"); for (int index = 0; index < 5000; index++) { insertPStmt.setInt(1, index); insertPStmt.setBytes(2, c1_value.getBytes("US-ASCII")); insertPStmt.setBytes(3, c2_value.getBytes("US-ASCII")); insertPStmt.setBytes(4, c3_value.getBytes("US-ASCII")); insertPStmt.setString(5, c4_value); insertPStmt.setString(6, c5_value); insertPStmt.setString(7, c6_value); insertPStmt.executeUpdate(); } insertPStmt.close(); // Do sort with maxFieldSize = 0 doSort(stmt); // Set maxFieldSize to 24 and do another sort stmt.setMaxFieldSize(24); doSort(stmt); }
Example 4
Source File: BrokeredStatement.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
void setStatementState(Statement oldStatement, Statement newStatement) throws SQLException { if (cursorName != null) newStatement.setCursorName(cursorName); if (escapeProcessing != null) newStatement.setEscapeProcessing(escapeProcessing.booleanValue()); newStatement.setFetchDirection(oldStatement.getFetchDirection()); newStatement.setFetchSize(oldStatement.getFetchSize()); newStatement.setMaxFieldSize(oldStatement.getMaxFieldSize()); newStatement.setMaxRows(oldStatement.getMaxRows()); newStatement.setQueryTimeout(oldStatement.getQueryTimeout()); }
Example 5
Source File: J2EEDataSourceTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** Create a statement with modified State. */ private Statement createFloatStatementForStateChecking( int[] StatementExpectedValues, Connection conn) throws SQLException { Statement s = internalCreateFloatStatementForStateChecking(conn); s.setCursorName("StokeNewington"); s.setFetchDirection(ResultSet.FETCH_REVERSE); s.setFetchSize(444); s.setMaxFieldSize(713); s.setMaxRows(19); // Create assertStatementState(null, StatementExpectedValues, s); return s; }
Example 6
Source File: maxfieldsize.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private static void testSort(Connection conn, Statement stmt) throws SQLException, java.io.UnsupportedEncodingException { PreparedStatement insertPStmt; // Load up a 2nd table using streams where appropriate stmt.execute("create table tab2("+ "c0 int, " + "c1 char(100) for bit data,"+ "c2 varchar(100) for bit data," + "c3 long varchar for bit data,"+ "c4 char(100),"+ "c5 varchar(100),"+ "c6 long varchar)"); // Populate the table insertPStmt = conn.prepareStatement( "insert into tab2 values (?, ?, ?, ?, ?, ?, ?)"); for (int index = 0; index < 5000; index++) { insertPStmt.setInt(1, index); insertPStmt.setBytes(2, c1_value.getBytes("US-ASCII")); insertPStmt.setBytes(3, c2_value.getBytes("US-ASCII")); insertPStmt.setBytes(4, c3_value.getBytes("US-ASCII")); insertPStmt.setString(5, c4_value); insertPStmt.setString(6, c5_value); insertPStmt.setString(7, c6_value); insertPStmt.executeUpdate(); } insertPStmt.close(); // Do sort with maxFieldSize = 0 doSort(stmt); // Set maxFieldSize to 24 and do another sort stmt.setMaxFieldSize(24); doSort(stmt); }
Example 7
Source File: BrokeredStatement.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
void setStatementState(Statement oldStatement, Statement newStatement) throws SQLException { if (cursorName != null) newStatement.setCursorName(cursorName); if (escapeProcessing != null) newStatement.setEscapeProcessing(escapeProcessing.booleanValue()); newStatement.setFetchDirection(oldStatement.getFetchDirection()); newStatement.setFetchSize(oldStatement.getFetchSize()); newStatement.setMaxFieldSize(oldStatement.getMaxFieldSize()); newStatement.setMaxRows(oldStatement.getMaxRows()); newStatement.setQueryTimeout(oldStatement.getQueryTimeout()); }
Example 8
Source File: BrokeredStatement.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
void setStatementState(Statement oldStatement, Statement newStatement) throws SQLException { if (cursorName != null) newStatement.setCursorName(cursorName); if (escapeProcessing != null) newStatement.setEscapeProcessing(escapeProcessing); newStatement.setFetchDirection(oldStatement.getFetchDirection()); newStatement.setFetchSize(oldStatement.getFetchSize()); newStatement.setMaxFieldSize(oldStatement.getMaxFieldSize()); newStatement.setMaxRows(oldStatement.getMaxRows()); newStatement.setQueryTimeout(oldStatement.getQueryTimeout()); }
Example 9
Source File: ResultSetStreamTest.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
/** * Tests that the max field size limit is handled correctly when accessing * values as streams. The limit should apply for VARCHAR, but not for CLOB. * * @throws IOException if something goes wrong * @throws SQLException if something goes wrong */ public void testSetMaxFieldSizeLarge() throws IOException, SQLException { // Insert test data. int id = 1; int clobSize = 2*1024*1024; // 2 MB int vcSize = 32672; int limit = 10; PreparedStatement ps = prepareStatement( "insert into setMaxFieldSize values (?,?,?)"); ps.setInt(1, id); ps.setCharacterStream(2, new LoopingAlphabetReader(vcSize), vcSize); ps.setCharacterStream(3, new LoopingAlphabetReader(clobSize), clobSize); ps.executeUpdate(); // Fetch data back with a limit. Statement stmt = createStatement(); stmt.setMaxFieldSize(limit); ResultSet rs = stmt.executeQuery("select dVarchar, dClob from " + "setMaxFieldSize where id = " + id); assertTrue(rs.next()); String vcStr = drainStringFromSource(rs.getCharacterStream(1)); // Limit should apply to VARCHAR. assertEquals(limit, vcStr.length()); // Limit should *not* apply to CLOB. String vsClob = drainStringFromSource(rs.getCharacterStream(2)); assertEquals(clobSize, vsClob.length()); rs.close(); // Again, but without a limit. stmt = createStatement(); rs = stmt.executeQuery("select dVarchar, dClob from " + "setMaxFieldSize where id = " + id); assertTrue(rs.next()); vcStr = drainStringFromSource(rs.getCharacterStream(1)); assertEquals(vcSize, vcStr.length()); vsClob = drainStringFromSource(rs.getCharacterStream(2)); assertEquals(clobSize, vsClob.length()); rs.close(); }
Example 10
Source File: J2EEDataSourceTest.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
/** Create a statement with modified State. */ private Statement createFloatStatementForStateChecking( int[] StatementExpectedValues, Connection conn) throws SQLException { Statement s = internalCreateFloatStatementForStateChecking(conn); s.setCursorName("StokeNewington"); s.setFetchDirection(ResultSet.FETCH_REVERSE); s.setFetchSize(444); s.setMaxFieldSize(713); s.setMaxRows(19); // Create assertStatementState(null, StatementExpectedValues, s); return s; }
Example 11
Source File: maxfieldsize.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
private static void testSort(Connection conn, Statement stmt) throws SQLException, java.io.UnsupportedEncodingException { PreparedStatement insertPStmt; // Load up a 2nd table using streams where appropriate stmt.execute("create table tab2("+ "c0 int, " + "c1 char(100) for bit data,"+ "c2 varchar(100) for bit data," + "c3 long varchar for bit data,"+ "c4 char(100),"+ "c5 varchar(100),"+ "c6 long varchar)"); // Populate the table insertPStmt = conn.prepareStatement( "insert into tab2 values (?, ?, ?, ?, ?, ?, ?)"); for (int index = 0; index < 5000; index++) { insertPStmt.setInt(1, index); insertPStmt.setBytes(2, c1_value.getBytes("US-ASCII")); insertPStmt.setBytes(3, c2_value.getBytes("US-ASCII")); insertPStmt.setBytes(4, c3_value.getBytes("US-ASCII")); insertPStmt.setString(5, c4_value); insertPStmt.setString(6, c5_value); insertPStmt.setString(7, c6_value); insertPStmt.executeUpdate(); } insertPStmt.close(); // Do sort with maxFieldSize = 0 doSort(stmt); // Set maxFieldSize to 24 and do another sort stmt.setMaxFieldSize(24); doSort(stmt); }
Example 12
Source File: SWStatementTest.java From skywalking with Apache License 2.0 | 4 votes |
@Test public void testPreparedStatementConfig() throws SQLException { Statement statement = swConnection.createStatement(); statement.cancel(); statement.getUpdateCount(); statement.setFetchDirection(1); statement.getFetchDirection(); statement.getResultSetConcurrency(); statement.getResultSetType(); statement.isClosed(); statement.setPoolable(false); statement.isPoolable(); statement.getWarnings(); statement.clearWarnings(); statement.setCursorName("test"); statement.setMaxFieldSize(11); statement.getMaxFieldSize(); statement.setMaxRows(10); statement.getMaxRows(); statement.setEscapeProcessing(true); statement.setFetchSize(1); statement.getFetchSize(); statement.setQueryTimeout(1); statement.getQueryTimeout(); Connection connection = statement.getConnection(); statement.execute("SELECT * FROM test"); statement.getMoreResults(); statement.getMoreResults(1); statement.getResultSetHoldability(); statement.getResultSet(); statement.close(); verify(mysqlStatement).getUpdateCount(); verify(mysqlStatement).getMoreResults(); verify(mysqlStatement).setFetchDirection(anyInt()); verify(mysqlStatement).getFetchDirection(); verify(mysqlStatement).getResultSetType(); verify(mysqlStatement).isClosed(); verify(mysqlStatement).setPoolable(anyBoolean()); verify(mysqlStatement).getWarnings(); verify(mysqlStatement).clearWarnings(); verify(mysqlStatement).setCursorName(anyString()); verify(mysqlStatement).setMaxFieldSize(anyInt()); verify(mysqlStatement).getMaxFieldSize(); verify(mysqlStatement).setMaxRows(anyInt()); verify(mysqlStatement).getMaxRows(); verify(mysqlStatement).setEscapeProcessing(anyBoolean()); verify(mysqlStatement).getResultSetConcurrency(); verify(mysqlStatement).getResultSetConcurrency(); verify(mysqlStatement).getResultSetType(); verify(mysqlStatement).getMoreResults(anyInt()); verify(mysqlStatement).setFetchSize(anyInt()); verify(mysqlStatement).getFetchSize(); verify(mysqlStatement).getQueryTimeout(); verify(mysqlStatement).setQueryTimeout(anyInt()); verify(mysqlStatement).getResultSet(); assertThat(connection, CoreMatchers.<Connection>is(swConnection)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); assertDBSpan(spans.get(0), "Mysql/JDBI/Statement/execute", "SELECT * FROM test"); }