Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf8d90fc

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
Protected access to variable m_preparedCount via synchronized
function to prevent multiple threads using automatic cursors onthe same connection from stomping over each others cursor.Jan
1 parent67afe3d commitf8d90fc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
importjava.sql.Types;
2727
importjava.util.Vector;
2828

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 $
3030
* This class defines methods of the jdbc1 specification. This class is
3131
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
3232
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
@@ -73,7 +73,15 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
7373
protectedbooleanm_statementIsCursor =false;
7474

7575
privatebooleanm_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.
7680
privatestaticintm_preparedCount =1;
81+
privatesynchronizedstaticintnext_preparedCount()
82+
{
83+
returnm_preparedCount++;
84+
}
7785

7886
//Used by the callablestatement style methods
7987
privatestaticfinalStringJDBC_SYNTAX ="{[? =] call <some_function> ([? [,?]*]) }";
@@ -316,7 +324,7 @@ public boolean execute() throws SQLException
316324
{
317325
if (m_statementName ==null)
318326
{
319-
m_statementName ="JDBC_STATEMENT_" +m_preparedCount++;
327+
m_statementName ="JDBC_STATEMENT_" +next_preparedCount();
320328
m_origSqlFragments =newString[m_sqlFragments.length];
321329
m_executeSqlFragments =newString[m_sqlFragments.length];
322330
System.arraycopy(m_sqlFragments,0,m_origSqlFragments,0,m_sqlFragments.length);
@@ -375,7 +383,7 @@ else if (fetchSize > 0 && !connection.getAutoCommit())
375383
// The first thing to do is transform the statement text into the cursor form.
376384
String[]cursorBasedSql =newString[m_sqlFragments.length];
377385
// Pinch the prepared count for our own nefarious purposes.
378-
StringstatementName ="JDBC_CURS_" +m_preparedCount++;
386+
StringstatementName ="JDBC_CURS_" +next_preparedCount();
379387
// Setup the cursor decleration.
380388
// Note that we don't need a BEGIN because we've already
381389
// made sure we're executing inside a transaction.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp