Skip to content

Commit 00d8ce0

Browse files
author
Aaron Johnson
committed
upstream branch [r1289]
jtds-code-1289-branches-jTDS 1.3 (stable).zip from, https://sourceforge.net/p/jtds/code/HEAD/tarball?path=/branches/jTDS%201.3%20(stable)
1 parent ee05add commit 00d8ce0

27 files changed

+2602
-1840
lines changed

Diff for: CHANGELOG

+36
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
Changes from jTDS 1.3.1
2+
=======================
3+
4+
11/14/2014 - Holger Rehn
5+
o Bugfix: The SQL parser's statement cache could have returned inappropriate
6+
results if multiple connections use different settings for "prepareSQL" or
7+
"sendStringParametersAsUnicode".
8+
9+
11/13/2014 - Holger Rehn
10+
o Bugfix: The size of the in-memory packet buffer wasn't monitored correctly,
11+
potentially causing the driver to occupy an unpredictable (large or small)
12+
amount of RAM buffer before switching to disk based caching.
13+
o Applied patch #129 provided by lkoniecki (improved by Bain) to fix bug #725.
14+
15+
05/30/2014 - Holger Rehn
16+
o Fixed bug #726, using setMaxRows() may affect batch operations performed on
17+
another Statement object using the same (physical) connection.
18+
19+
10/29/2013 - Holger Rehn
20+
o Fixed savepoint functionality for Sybase ASE that has been broken by the fix
21+
for bug #569.
22+
23+
10/28/2013 - Holger Rehn
24+
o Fixed a bug that could cause an empty value being returned as a single
25+
whitespace when using Sybase ASE.
26+
27+
10/15/2013 - Holger Rehn
28+
o Implemented support for the COMPUTE (BY) operator (bug #678) for Sybase ASE.
29+
30+
09/06/2013 - Holger Rehn
31+
o Removed synchronization from method getAutoCommit().
32+
33+
09/03/2013 - Holger Rehn
34+
o Fixed bug #715, infinite loop when parsing an SQL command.
35+
o Fixed bug #710, invalid property handling in JtdsObjectFactory.
36+
137
===============================================================================
238
06/08/2013 - jTDS 1.3.1 released
339
===============================================================================

Diff for: src/main/net/sourceforge/jtds/jdbc/CachedResultSet.java

+23-29
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ public class CachedResultSet extends JtdsResultSet {
7575
/** True if this is a local temporary result set. */
7676
protected final boolean tempResultSet;
7777
/** Cursor TdsCore object. */
78-
protected final TdsCore cursorTds;
78+
protected TdsCore cursorTds;
7979
/** Updates TdsCore object used for positioned updates. */
80-
protected final TdsCore updateTds;
80+
protected TdsCore updateTds;
8181
/** Flag to indicate Sybase. */
8282
protected boolean isSybase;
8383
/** Fetch size has been changed. */
@@ -172,8 +172,6 @@ public class CachedResultSet extends JtdsResultSet {
172172
pos = POS_BEFORE_FIRST;
173173
tempResultSet = true;
174174
cursorName = null;
175-
cursorTds = null;
176-
updateTds = null;
177175
procName = null;
178176
procedureParams = null;
179177
}
@@ -220,8 +218,6 @@ public class CachedResultSet extends JtdsResultSet {
220218
pos = POS_BEFORE_FIRST;
221219
tempResultSet = true;
222220
cursorName = null;
223-
cursorTds = null;
224-
updateTds = null;
225221
procName = null;
226222
procedureParams = null;
227223
//
@@ -254,8 +250,6 @@ public class CachedResultSet extends JtdsResultSet {
254250
tempResultSet = true;
255251
cursorName = null;
256252
rowData.add(copyRow(data));
257-
cursorTds = null;
258-
updateTds = null;
259253
procName = null;
260254
procedureParams = null;
261255
}
@@ -371,9 +365,7 @@ private void cursorCreate()
371365
}
372366
}
373367
cursorSQL.append(sql);
374-
cursorTds.executeSQL(cursorSQL.toString(), null, parameters,
375-
false, statement.getQueryTimeout(), statement.getMaxRows(),
376-
statement.getMaxFieldSize(), true);
368+
cursorTds.executeSQL(cursorSQL.toString(), null, parameters, false, statement.getQueryTimeout(), statement.getMaxRows(), statement.getMaxFieldSize(), true);
377369
cursorTds.clearResponseQueue();
378370
cursorTds.getMessages().checkErrors();
379371
//
@@ -386,9 +378,7 @@ private void cursorCreate()
386378
cursorSQL.append(" FOR ").append(cursorName);
387379
}
388380
cursorSQL.append("\r\nFETCH ").append(cursorName);
389-
cursorTds.executeSQL(cursorSQL.toString(), null, null, false,
390-
statement.getQueryTimeout(), statement.getMaxRows(),
391-
statement.getMaxFieldSize(), true);
381+
cursorTds.executeSQL(cursorSQL.toString(), null, null, false, statement.getQueryTimeout(), statement.getMaxRows(), statement.getMaxFieldSize(), true);
392382
//
393383
// Check we have a result set
394384
//
@@ -424,15 +414,11 @@ private void cursorCreate()
424414
// OK Should have an SQL select statement
425415
// append " FOR BROWSE" to obtain table names
426416
// NB. We can't use any jTDS temporary stored proc
427-
cursorTds.executeSQL(sql + " FOR BROWSE", null, procedureParams,
428-
false, statement.getQueryTimeout(),
429-
statement.getMaxRows(), statement.getMaxFieldSize(),
430-
true);
417+
cursorTds.executeSQL(sql + " FOR BROWSE", null, procedureParams, false, statement.getQueryTimeout(), statement.getMaxRows(), statement.getMaxFieldSize(), true);
431418
while (!cursorTds.getMoreResults() && !cursorTds.isEndOfResponse());
432419
if (!cursorTds.isResultSet()) {
433420
// Throw exception but queue up any others
434-
SQLException ex = new SQLException(
435-
Messages.get("error.statement.noresult"), "24000");
421+
SQLException ex = new SQLException( Messages.get("error.statement.noresult"), "24000");
436422
ex.setNextException(statement.getMessages().exceptions);
437423
throw ex;
438424
}
@@ -1024,16 +1010,24 @@ public void cancelRowUpdates() throws SQLException {
10241010
}
10251011
}
10261012

1027-
public void close() throws SQLException {
1028-
if (!closed) {
1029-
try {
1030-
cursorClose();
1031-
} finally {
1032-
closed = true;
1033-
statement = null;
1034-
}
1013+
public void close()
1014+
throws SQLException
1015+
{
1016+
if( ! closed )
1017+
{
1018+
try
1019+
{
1020+
cursorClose();
10351021
}
1036-
}
1022+
finally
1023+
{
1024+
closed = true;
1025+
statement = null;
1026+
cursorTds = null;
1027+
updateTds = null;
1028+
}
1029+
}
1030+
}
10371031

10381032
public void deleteRow() throws SQLException {
10391033
checkOpen();

Diff for: src/main/net/sourceforge/jtds/jdbc/JtdsCallableStatement.java

+109-77
Original file line numberDiff line numberDiff line change
@@ -139,87 +139,119 @@ protected void checkOpen() throws SQLException {
139139
}
140140
}
141141

142-
/**
143-
* Execute the SQL batch on a MS server.
144-
* @param size the total size of the batch.
145-
* @param executeSize the maximum number of statements to send in one request.
146-
* @param counts the returned update counts.
147-
* @return Chained exceptions linked to a <code>SQLException</code>.
148-
* @throws SQLException
149-
*/
150-
@Override
151-
protected SQLException executeMSBatch(int size, int executeSize, ArrayList counts)
152-
throws SQLException {
153-
if (parameters.length == 0) {
154-
// No parameters so we can execute as a simple batch
155-
return super.executeMSBatch(size, executeSize, counts);
156-
}
157-
SQLException sqlEx = null;
158-
for (int i = 0; i < size;) {
159-
Object value = batchValues.get(i);
160-
++i;
161-
// Execute batch now if max size reached or end of batch
162-
boolean executeNow = (i % executeSize == 0) || i == size;
163-
164-
tds.startBatch();
165-
tds.executeSQL(sql, procName, (ParamInfo[]) value, false, 0, -1, -1, executeNow);
166-
167-
// If the batch has been sent, process the results
168-
if (executeNow) {
169-
sqlEx = tds.getBatchCounts(counts, sqlEx);
170-
171-
// If a serious error then we stop execution now as count
172-
// is too small.
173-
if (sqlEx != null && counts.size() != i) {
174-
break;
175-
}
176-
}
177-
}
178-
return sqlEx;
179-
}
180-
181-
/**
182-
* Execute the SQL batch on a Sybase server.
183-
* <p/>
184-
* For the rare case of CallableStatement batches each statement is executed individually. This ensures that
185-
* problems with the server reading into the middle of a statement are avoided. See bug report [1374518] for more
186-
* details.
187-
*
188-
* @param size the total size of the batch
189-
* @param executeSize the maximum number of statements to send in one request (ignored for this version of the
190-
* method as only one statement will be sent at a time)
191-
* @param counts the returned update counts
192-
* @return chained exceptions linked to a <code>SQLException</code>
193-
* @throws SQLException if a serious error occurs during execution
194-
*/
195-
@Override
196-
protected SQLException executeSybaseBatch(int size, int executeSize, ArrayList counts)
197-
throws SQLException
198-
{
199-
if (parameters.length == 0) {
200-
// No parameters so we can execute as a simple batch
201-
return super.executeSybaseBatch(size, executeSize, counts);
202-
}
203-
204-
SQLException sqlEx = null;
205-
206-
for (int i = 0; i < size;) {
207-
Object value = batchValues.get(i);
208-
++i;
209-
tds.executeSQL(sql, procName, (ParamInfo[]) value, false, 0, -1, -1, true);
210-
211-
// If the batch has been sent, process the results
212-
sqlEx = tds.getBatchCounts(counts, sqlEx);
142+
/**
143+
* Execute the SQL batch on a MS server.
144+
*
145+
* @param size
146+
* total size of the batch
147+
*
148+
* @param executeSize
149+
* maximum number of statements to send in one request
150+
*
151+
* @param counts
152+
* the returned update counts
153+
*
154+
* @return
155+
* chained exceptions linked to a <code>SQLException</code>
156+
*
157+
* @throws SQLException
158+
*/
159+
@Override
160+
protected SQLException executeMSBatch( int size, int executeSize, ArrayList counts )
161+
throws SQLException
162+
{
163+
if( parameters.length == 0 )
164+
{
165+
// No parameters so we can execute as a simple batch
166+
return super.executeMSBatch( size, executeSize, counts );
167+
}
168+
169+
SQLException sqlEx = null;
170+
for( int i = 0; i < size; )
171+
{
172+
Object value = batchValues.get( i );
173+
++ i;
174+
175+
// Execute batch now if max size reached or end of batch
176+
boolean executeNow = (i % executeSize == 0) || i == size;
177+
178+
tds.startBatch();
179+
180+
// provide statement's ROWCOUNT and TEXTSIZE (see bug #726)
181+
tds.executeSQL( sql, procName, (ParamInfo[]) value, false, 0, maxRows, maxFieldSize, executeNow );
182+
183+
// If the batch has been sent, process the results
184+
if( executeNow )
185+
{
186+
sqlEx = tds.getBatchCounts( counts, sqlEx );
213187

214188
// If a serious error then we stop execution now as count
215189
// is too small.
216-
if (sqlEx != null && counts.size() != i) {
217-
break;
190+
if( sqlEx != null && counts.size() != i )
191+
{
192+
break;
218193
}
219-
}
220-
return sqlEx;
221-
}
222-
194+
}
195+
}
196+
return sqlEx;
197+
}
198+
199+
/**
200+
* <p> Execute the SQL batch on a Sybase server. </p>
201+
*
202+
* <p> For the rare case of CallableStatement batches each statement is
203+
* executed individually. This ensures that problems with the server reading
204+
* into the middle of a statement are avoided. See bug report [1374518] for
205+
* more details. </p>
206+
*
207+
* @param size
208+
* total size of the batch
209+
*
210+
* @param executeSize
211+
* maximum number of statements to send in one request (ignored for this
212+
* version of the method as only one statement will be sent at a time)
213+
*
214+
* @param counts
215+
* returned update counts
216+
*
217+
* @return
218+
* chained exceptions linked to a <code>SQLException</code>
219+
*
220+
* @throws SQLException
221+
* if a serious error occurs during execution
222+
*/
223+
@Override
224+
protected SQLException executeSybaseBatch( int size, int executeSize, ArrayList counts )
225+
throws SQLException
226+
{
227+
if( parameters.length == 0 )
228+
{
229+
// no parameters so we can execute as a simple batch
230+
return super.executeSybaseBatch( size, executeSize, counts );
231+
}
232+
233+
SQLException sqlEx = null;
234+
235+
for( int i = 0; i < size; )
236+
{
237+
Object value = batchValues.get( i );
238+
++ i;
239+
240+
// provide statement's ROWCOUNT and TEXTSIZE (see bug #726)
241+
tds.executeSQL( sql, procName, (ParamInfo[]) value, false, 0, maxRows, maxFieldSize, true );
242+
243+
// If the batch has been sent, process the results
244+
sqlEx = tds.getBatchCounts( counts, sqlEx );
245+
246+
// If a serious error then we stop execution now as count is too small.
247+
if( sqlEx != null && counts.size() != i )
248+
{
249+
break;
250+
}
251+
}
252+
253+
return sqlEx;
254+
}
223255

224256
// ---------- java.sql.CallableStatement methods follow ----------
225257

0 commit comments

Comments
 (0)