Java Code Examples for java.sql.ResultSet#updateCharacterStream()
The following examples show how to use
java.sql.ResultSet#updateCharacterStream() .
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: ResultSetTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testUpdateCharacterStreamLengthlessParameterName() throws IOException, SQLException { String str = "This is the (\u0FFF\u1234) test string"; String strUpdated = "An updated (\u0FEF\u9876) test string"; // Insert test data PreparedStatement psChar = prep("dLongVarchar"); psChar.setInt(1, key); psChar.setCharacterStream(2, new StringReader(str)); psChar.execute(); psChar.close(); // Update test data ResultSet rs = fetchUpd("dLongVarchar", key); rs.next(); rs.updateCharacterStream("dLongVarchar", new StringReader(strUpdated)); rs.updateRow(); rs.close(); // Verify that update took place and is correct. rs = fetch("dLongVarchar", key); rs.next(); Reader updatedStr = rs.getCharacterStream(1); for (int i=0; i < strUpdated.length(); i++) { assertEquals("Strings differ at index " + i, strUpdated.charAt(i), updatedStr.read()); } assertEquals("Too much data in stream", -1, updatedStr.read()); updatedStr.close(); }
Example 2
Source File: ResultSetTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testUpdateCharacterStreamLengthless() throws IOException, SQLException { String str = "This is the (\u0FFF\u1234) test string"; String strUpdated = "An updated (\u0FEF\u9876) test string"; // Insert test data PreparedStatement psChar = prep("dLongVarchar"); psChar.setInt(1, key); psChar.setCharacterStream(2, new StringReader(str)); psChar.execute(); psChar.close(); // Update test data ResultSet rs = fetchUpd("dLongVarchar", key); rs.next(); rs.updateCharacterStream(1, new StringReader(strUpdated)); rs.updateRow(); rs.close(); // Verify that update took place and is correct. rs = fetch("dLongVarchar", key); rs.next(); Reader updatedStr = rs.getCharacterStream(1); for (int i=0; i < strUpdated.length(); i++) { assertEquals("Strings differ at index " + i, strUpdated.charAt(i), updatedStr.read()); } assertEquals("Too much data in stream", -1, updatedStr.read()); updatedStr.close(); }
Example 3
Source File: WebSphereMsSqlServerDbmsSupport.java From iaf with Apache License 2.0 | 5 votes |
public void updateClob(ResultSet rs, String column, Object clobUpdateHandle) throws SQLException, JdbcException { File clobFile = (File)clobUpdateHandle; try { InputStream is = new FileInputStream(clobFile); Reader isr = StreamUtil.getCharsetDetectingInputStreamReader(is); rs.updateCharacterStream(column, isr, (int)clobFile.length()); // FIXME: should use character count instead of byte count! } catch (Exception e) { throw new JdbcException("cannot read clob for column ["+column+"] from file ["+clobFile.toString()+"]",e); } }
Example 4
Source File: WebSphereMsSqlServerDbmsSupport.java From iaf with Apache License 2.0 | 5 votes |
public void updateClob(ResultSet rs, int column, Object clobUpdateHandle) throws SQLException, JdbcException { File clobFile = (File)clobUpdateHandle; try { InputStream is = new FileInputStream(clobFile); Reader isr = StreamUtil.getCharsetDetectingInputStreamReader(is); rs.updateCharacterStream(column, isr, (int)clobFile.length()); // FIXME: should use character count instead of byte count! } catch (Exception e) { throw new JdbcException("cannot read clob for column ["+column+"] from file ["+clobFile.toString()+"]",e); } }
Example 5
Source File: ResultSetTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testUpdateCharacterStreamLengthless() throws IOException, SQLException { String str = "This is the (\u0FFF\u1234) test string"; String strUpdated = "An updated (\u0FEF\u9876) test string"; // Insert test data PreparedStatement psChar = prep("dLongVarchar"); psChar.setInt(1, key); psChar.setCharacterStream(2, new StringReader(str)); psChar.execute(); psChar.close(); // Update test data ResultSet rs = fetchUpd("dLongVarchar", key); rs.next(); rs.updateCharacterStream(1, new StringReader(strUpdated)); rs.updateRow(); rs.close(); // Verify that update took place and is correct. rs = fetch("dLongVarchar", key); rs.next(); Reader updatedStr = rs.getCharacterStream(1); for (int i=0; i < strUpdated.length(); i++) { assertEquals("Strings differ at index " + i, strUpdated.charAt(i), updatedStr.read()); } assertEquals("Too much data in stream", -1, updatedStr.read()); updatedStr.close(); }
Example 6
Source File: ResultSetTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testUpdateCharacterStreamLengthlessParameterName() throws IOException, SQLException { String str = "This is the (\u0FFF\u1234) test string"; String strUpdated = "An updated (\u0FEF\u9876) test string"; // Insert test data PreparedStatement psChar = prep("dLongVarchar"); psChar.setInt(1, key); psChar.setCharacterStream(2, new StringReader(str)); psChar.execute(); psChar.close(); // Update test data ResultSet rs = fetchUpd("dLongVarchar", key); rs.next(); rs.updateCharacterStream("dLongVarchar", new StringReader(strUpdated)); rs.updateRow(); rs.close(); // Verify that update took place and is correct. rs = fetch("dLongVarchar", key); rs.next(); Reader updatedStr = rs.getCharacterStream(1); for (int i=0; i < strUpdated.length(); i++) { assertEquals("Strings differ at index " + i, strUpdated.charAt(i), updatedStr.read()); } assertEquals("Too much data in stream", -1, updatedStr.read()); updatedStr.close(); }
Example 7
Source File: ResultSetTest.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public void testUpdateCharacterStreamLengthlessParameterName() throws IOException, SQLException { String str = "This is the (\u0FFF\u1234) test string"; String strUpdated = "An updated (\u0FEF\u9876) test string"; // Insert test data PreparedStatement psChar = prep("dLongVarchar"); psChar.setInt(1, key); psChar.setCharacterStream(2, new StringReader(str)); psChar.execute(); psChar.close(); // Update test data ResultSet rs = fetchUpd("dLongVarchar", key); rs.next(); rs.updateCharacterStream("dLongVarchar", new StringReader(strUpdated)); rs.updateRow(); rs.close(); // Verify that update took place and is correct. rs = fetch("dLongVarchar", key); rs.next(); Reader updatedStr = rs.getCharacterStream(1); for (int i=0; i < strUpdated.length(); i++) { assertEquals("Strings differ at index " + i, strUpdated.charAt(i), updatedStr.read()); } assertEquals("Too much data in stream", -1, updatedStr.read()); updatedStr.close(); }
Example 8
Source File: ResultSetTest.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
/** * This methods tests the ResultSet interface method * updateCharacterStream * * @throws SQLException if some error occurs while calling the method */ public void testUpdateCharacterStream() throws Exception { String str = "Test data"; String str_for_update = "Test data used for update"; StringReader r = new StringReader(str); StringReader r_for_update = new StringReader (str_for_update); //Prepared Statement used to insert the data PreparedStatement ps_sb = prep("dLongVarchar"); ps_sb.setInt(1,key); ps_sb.setCharacterStream(2,r,str.length()); ps_sb.executeUpdate(); ps_sb.close(); //Update operation //use a different ResultSet variable so that the //other tests can go on unimpacted ResultSet rs1 = fetchUpd("dLongVarchar", key); rs1.next(); rs1.updateCharacterStream(1,r_for_update,str_for_update.length()); rs1.updateRow(); rs1.close(); //Query to see whether the data that has been updated //using the updateAsciiStream method is the same //data that we expected rs1 = fetch("dLongVarchar", key); rs1.next(); StringReader r_ret = (StringReader)rs1.getCharacterStream(1); char [] c_ret = new char[str_for_update.length()]; r_ret.read(c_ret); String str_ret = new String(c_ret); assertEquals("Error in updateCharacterStream" + str_ret,str_for_update,str_ret); rs1.close(); }
Example 9
Source File: ResultSetTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * This methods tests the ResultSet interface method * updateCharacterStream * * @throws SQLException if some error occurs while calling the method */ public void testUpdateCharacterStreamStringParameterName() throws Exception { String str = "Test data"; String str_for_update = "Test data used for update"; StringReader r = new StringReader(str); StringReader r_for_update = new StringReader (str_for_update); //Prepared Statement used to insert the data PreparedStatement ps_sb = prep("dLongVarchar"); ps_sb.setInt(1, key); ps_sb.setCharacterStream(2,r,str.length()); ps_sb.executeUpdate(); ps_sb.close(); //Update operation //use a different ResultSet variable so that the //other tests can go on unimpacted ResultSet rs1 = fetchUpd("dLongVarchar", key); rs1.next(); rs1.updateCharacterStream("dLongVarchar", r_for_update, str_for_update.length()); rs1.updateRow(); rs1.close(); //Query to see whether the data that has been updated //using the updateAsciiStream method is the same //data that we expected rs1 = fetch("dLongVarchar", key); rs1.next(); StringReader r_ret = (StringReader)rs1.getCharacterStream(1); char [] c_ret = new char[str_for_update.length()]; r_ret.read(c_ret); String str_ret = new String(c_ret); assertEquals("Error in updateCharacterStream" + str_ret,str_for_update, str_ret); rs1.close(); }
Example 10
Source File: ResultSetTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * This methods tests the ResultSet interface method * updateCharacterStream * * @throws SQLException if some error occurs while calling the method */ public void testUpdateCharacterStream() throws Exception { String str = "Test data"; String str_for_update = "Test data used for update"; StringReader r = new StringReader(str); StringReader r_for_update = new StringReader (str_for_update); //Prepared Statement used to insert the data PreparedStatement ps_sb = prep("dLongVarchar"); ps_sb.setInt(1,key); ps_sb.setCharacterStream(2,r,str.length()); ps_sb.executeUpdate(); ps_sb.close(); //Update operation //use a different ResultSet variable so that the //other tests can go on unimpacted ResultSet rs1 = fetchUpd("dLongVarchar", key); rs1.next(); rs1.updateCharacterStream(1,r_for_update,str_for_update.length()); rs1.updateRow(); rs1.close(); //Query to see whether the data that has been updated //using the updateAsciiStream method is the same //data that we expected rs1 = fetch("dLongVarchar", key); rs1.next(); StringReader r_ret = (StringReader)rs1.getCharacterStream(1); char [] c_ret = new char[str_for_update.length()]; r_ret.read(c_ret); String str_ret = new String(c_ret); assertEquals("Error in updateCharacterStream" + str_ret,str_for_update,str_ret); rs1.close(); }
Example 11
Source File: UnsupportedUpdateOperationResultSetTest.java From shardingsphere with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateCharacterStreamForColumnLabelWithLongLength() throws SQLException { for (ResultSet each : resultSets) { each.updateCharacterStream("label", new StringReader(""), 1L); } }
Example 12
Source File: UnsupportedUpdateOperationResultSetTest.java From shardingsphere with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateCharacterStreamForColumnIndexWithLongLength() throws SQLException { for (ResultSet each : resultSets) { each.updateCharacterStream(1, new StringReader(""), 1L); } }
Example 13
Source File: UnsupportedUpdateOperationResultSetTest.java From shardingsphere with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateCharacterStreamForColumnLabelWithIntegerLength() throws SQLException { for (ResultSet each : resultSets) { each.updateCharacterStream("label", new StringReader(""), 1); } }
Example 14
Source File: UnsupportedUpdateOperationResultSetTest.java From shardingsphere with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateCharacterStreamForColumnLabel() throws SQLException { for (ResultSet each : resultSets) { each.updateCharacterStream("label", new StringReader("")); } }
Example 15
Source File: UnsupportedUpdateOperationResultSetTest.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateCharacterStreamForColumnIndex() throws SQLException { for (ResultSet each : resultSets) { each.updateCharacterStream(1, new StringReader("")); } }
Example 16
Source File: ResultSetTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * This methods tests the ResultSet interface method * updateCharacterStream * * @throws SQLException if some error occurs while calling the method */ public void testUpdateCharacterStreamStringParameterName() throws Exception { String str = "Test data"; String str_for_update = "Test data used for update"; StringReader r = new StringReader(str); StringReader r_for_update = new StringReader (str_for_update); //Prepared Statement used to insert the data PreparedStatement ps_sb = prep("dLongVarchar"); ps_sb.setInt(1, key); ps_sb.setCharacterStream(2,r,str.length()); ps_sb.executeUpdate(); ps_sb.close(); //Update operation //use a different ResultSet variable so that the //other tests can go on unimpacted ResultSet rs1 = fetchUpd("dLongVarchar", key); rs1.next(); rs1.updateCharacterStream("dLongVarchar", r_for_update, str_for_update.length()); rs1.updateRow(); rs1.close(); //Query to see whether the data that has been updated //using the updateAsciiStream method is the same //data that we expected rs1 = fetch("dLongVarchar", key); rs1.next(); StringReader r_ret = (StringReader)rs1.getCharacterStream(1); char [] c_ret = new char[str_for_update.length()]; r_ret.read(c_ret); String str_ret = new String(c_ret); assertEquals("Error in updateCharacterStream" + str_ret,str_for_update, str_ret); rs1.close(); }
Example 17
Source File: ResultSetTest.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
/** * This methods tests the ResultSet interface method * updateCharacterStream * * @throws SQLException if some error occurs while calling the method */ public void testUpdateCharacterStreamStringParameterName() throws Exception { String str = "Test data"; String str_for_update = "Test data used for update"; StringReader r = new StringReader(str); StringReader r_for_update = new StringReader (str_for_update); //Prepared Statement used to insert the data PreparedStatement ps_sb = prep("dLongVarchar"); ps_sb.setInt(1, key); ps_sb.setCharacterStream(2,r,str.length()); ps_sb.executeUpdate(); ps_sb.close(); //Update operation //use a different ResultSet variable so that the //other tests can go on unimpacted ResultSet rs1 = fetchUpd("dLongVarchar", key); rs1.next(); rs1.updateCharacterStream("dLongVarchar", r_for_update, str_for_update.length()); rs1.updateRow(); rs1.close(); //Query to see whether the data that has been updated //using the updateAsciiStream method is the same //data that we expected rs1 = fetch("dLongVarchar", key); rs1.next(); StringReader r_ret = (StringReader)rs1.getCharacterStream(1); char [] c_ret = new char[str_for_update.length()]; r_ret.read(c_ret); String str_ret = new String(c_ret); assertEquals("Error in updateCharacterStream" + str_ret,str_for_update, str_ret); rs1.close(); }
Example 18
Source File: UnsupportedUpdateOperationResultSetTest.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateCharacterStreamForColumnLabelWithIntegerLength() throws SQLException { for (ResultSet each : resultSets) { each.updateCharacterStream("label", new StringReader(""), 1); } }
Example 19
Source File: UnsupportedUpdateOperationResultSetTest.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateCharacterStreamForColumnIndexWithIntegerLength() throws SQLException { for (ResultSet each : resultSets) { each.updateCharacterStream(1, new StringReader(""), 1); } }
Example 20
Source File: UnsupportedUpdateOperationResultSetTest.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateCharacterStreamForColumnLabel() throws SQLException { for (ResultSet each : resultSets) { each.updateCharacterStream("label", new StringReader("")); } }