|
26 | 26 | import java.sql.Types;
|
27 | 27 | import java.util.Vector;
|
28 | 28 |
|
29 |
| -/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.39 2003/09/23 06:13:52 barry Exp $ |
| 29 | +/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.40 2003/10/09 01:17:07 wieck Exp $ |
30 | 30 | * This class defines methods of the jdbc1 specification. This class is
|
31 | 31 | * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
|
32 | 32 | * methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
|
@@ -73,7 +73,15 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
|
73 | 73 | protected boolean m_statementIsCursor = false;
|
74 | 74 |
|
75 | 75 | private boolean m_useServerPrepare = false;
|
| 76 | + |
| 77 | + // m_preparedCount is used for naming of auto-cursors and must |
| 78 | + // be synchronized so that multiple threads using the same |
| 79 | + // connection don't stomp over each others cursors. |
76 | 80 | private static int m_preparedCount = 1;
|
| 81 | + private synchronized static int next_preparedCount() |
| 82 | + { |
| 83 | + return m_preparedCount++; |
| 84 | + } |
77 | 85 |
|
78 | 86 | //Used by the callablestatement style methods
|
79 | 87 | private static final String JDBC_SYNTAX = "{[? =] call <some_function> ([? [,?]*]) }";
|
@@ -316,7 +324,7 @@ public boolean execute() throws SQLException
|
316 | 324 | {
|
317 | 325 | if (m_statementName == null)
|
318 | 326 | {
|
319 |
| - m_statementName = "JDBC_STATEMENT_" + m_preparedCount++; |
| 327 | + m_statementName = "JDBC_STATEMENT_" + next_preparedCount(); |
320 | 328 | m_origSqlFragments = new String[m_sqlFragments.length];
|
321 | 329 | m_executeSqlFragments = new String[m_sqlFragments.length];
|
322 | 330 | System.arraycopy(m_sqlFragments, 0, m_origSqlFragments, 0, m_sqlFragments.length);
|
@@ -375,7 +383,7 @@ else if (fetchSize > 0 && !connection.getAutoCommit())
|
375 | 383 | // The first thing to do is transform the statement text into the cursor form.
|
376 | 384 | String[] cursorBasedSql = new String[m_sqlFragments.length];
|
377 | 385 | // Pinch the prepared count for our own nefarious purposes.
|
378 |
| - String statementName = "JDBC_CURS_" + m_preparedCount++; |
| 386 | + String statementName = "JDBC_CURS_" + next_preparedCount(); |
379 | 387 | // Setup the cursor decleration.
|
380 | 388 | // Note that we don't need a BEGIN because we've already
|
381 | 389 | // made sure we're executing inside a transaction.
|
|
0 commit comments