@@ -92,34 +92,35 @@ public long position(String searchstr, long start) throws SQLException {
9292
9393 @ Override
9494 public long position (Clob searchstr , long start ) throws SQLException {
95- throw new UnsupportedOperationException ( "Clob may not be manipulated from creating session" );
95+ throw notSupported ( );
9696 }
9797
9898 @ Override
9999 public int setString (long pos , String str ) throws SQLException {
100- throw new UnsupportedOperationException ( "Clob may not be manipulated from creating session" );
100+ throw notSupported ( );
101101 }
102102
103103 @ Override
104104 public int setString (long pos , String str , int offset , int len ) throws SQLException {
105- throw new UnsupportedOperationException ( "Clob may not be manipulated from creating session" );
105+ throw notSupported ( );
106106 }
107107
108108 @ Override
109109 public OutputStream setAsciiStream (long pos ) {
110- throw new UnsupportedOperationException ( "Clob may not be manipulated from creating session" );
110+ throw notSupported ( );
111111 }
112112
113113 @ Override
114114 public Writer setCharacterStream (long pos ) {
115- throw new UnsupportedOperationException ( "Clob may not be manipulated from creating session" );
115+ throw notSupported ( );
116116 }
117117
118118 @ Override
119119 public void truncate (long len ) throws SQLException {
120- throw new UnsupportedOperationException ( "Clob may not be manipulated from creating session" );
120+ throw notSupported ( );
121121 }
122122
123+ @ Override
123124 public String getSubString (long start , int length ) throws SQLException {
124125 if ( start < 1 ) {
125126 throw new SQLException ( "Start position 1-based; must be 1 or more." );
@@ -143,8 +144,11 @@ public Reader getCharacterStream(long start, long length) throws SQLException {
143144 if ( start > length () + 1 ) {
144145 throw new SQLException ( "Start position [" + start + "] cannot exceed overall CLOB length [" + length () + "]" );
145146 }
147+ if ( length > Integer .MAX_VALUE ) {
148+ throw new SQLException ( "Can't deal with Clobs larger than 'Integer.MAX_VALUE'" );
149+ }
146150 if ( length < 0 ) {
147- // javadoc for getCharacterStream(long,int) specify that the start+length must not exceed the
151+ // javadoc for getCharacterStream(long,int) specifies that the start+length must not exceed the
148152 // total length (this is at odds with the behavior of getSubString(long,int))
149153 throw new SQLException ( "Length must be greater than or equal to zero" );
150154 }
@@ -190,4 +194,8 @@ public static Clob generateProxy(String string) {
190194 public static Clob generateProxy (Reader reader , long length ) {
191195 return new ClobProxy ( reader , length );
192196 }
197+
198+ private static UnsupportedOperationException notSupported () {
199+ return new UnsupportedOperationException ("Clob may not be manipulated from creating session" );
200+ }
193201}
0 commit comments