import java.sql.Types;
import java.util.Vector;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.39 2003/09/23 06:13:52 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.40 2003/10/09 01:17:07 wieck Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
protected boolean m_statementIsCursor = false;
private boolean m_useServerPrepare = false;
+
+ // m_preparedCount is used for naming of auto-cursors and must
+ // be synchronized so that multiple threads using the same
+ // connection don't stomp over each others cursors.
private static int m_preparedCount = 1;
+ private synchronized static int next_preparedCount()
+ {
+ return m_preparedCount++;
+ }
//Used by the callablestatement style methods
private static final String JDBC_SYNTAX = "{[? =] call <some_function> ([? [,?]*]) }";
{
if (m_statementName == null)
{
- m_statementName = "JDBC_STATEMENT_" + m_preparedCount++;
+ m_statementName = "JDBC_STATEMENT_" + next_preparedCount();
m_origSqlFragments = new String[m_sqlFragments.length];
m_executeSqlFragments = new String[m_sqlFragments.length];
System.arraycopy(m_sqlFragments, 0, m_origSqlFragments, 0, m_sqlFragments.length);
// The first thing to do is transform the statement text into the cursor form.
String[] cursorBasedSql = new String[m_sqlFragments.length];
// Pinch the prepared count for our own nefarious purposes.
- String statementName = "JDBC_CURS_" + m_preparedCount++;
+ String statementName = "JDBC_CURS_" + next_preparedCount();
// Setup the cursor decleration.
// Note that we don't need a BEGIN because we've already
// made sure we're executing inside a transaction.