http://java.sun.com/j2se/1.3/docs/guide/jdbc/spec/jdbc-spec.frame9.html
states in section 9.2
"9.2 Multi-threading
We require that all operations on all the java.sql objects be multi-thread safe and able to cope correctly with having several threads simultaneously calling the same object.
Some drivers may allow more concurrent execution than others. Developers can assume fully concurrent execution; if the driver requires some form of synchronization, it will provide it. The only difference visible to the developer will be that applications will run with reduced concurrency.
For example, two Statements on the same Connection can be executed concurrently and their ResultSets can be processed concurrently (from the perspective of the developer). Some drivers will provide this full concurrency. Others may execute one statement and wait until it completes before sending the next.
One specific use of multi-threading is to cancel a long running statement. This is done by using one thread to execute the statement and another to cancel it with its Statement.cancel() method.
In practice we expect that most of the JDBC objects will only be accessed in a single threaded way. However some multi-thread support is necessary, and our attempts in previous drafts to specify some classes as MT safe and some as MT unsafe appeared to be adding more confusion than light. "
Please note this section states that the developer can assume fully
concurrent execution and that two statements on the same Connection
can be run concurrently and the result sets will be processed concurrently.
Martin P. Smith
Beansmith Technologies
At 05:00 PM 3/5/2002 +0100, Paskamp, Marco wrote:
see answer from Edson Carlos Ericksson Richter below:
-----Original Message-----
From: Edson Carlos Ericksson Richter
[mailto:[EMAIL PROTECTED]]
Sent: Dienstag, 5. M�rz 2002 16:31
To: Paskamp, Marco
Subject: RES: Is the JDBC Driver multi thread / servlet safe?
I have several applications that uses JDBC driver, and I had no problems. I
make use of tons on connections in Web Apps, Servlets and EJB. The only
thing that I make in my code is not share connections between apps. Every
method that need to access database uses their own connection, and just
before method ends, I close the connection.
This works fine with not only SapDB, but Oracle 8i, Sybase System11 and MS
SQL Server.
Atenciosamente,
Edson Carlos Ericksson Richter
Gerente de Tecnologia
ECONET Solu��es Web
+55 61 326 5115
-----Mensagem original-----
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]Em nome de Paskamp, Marco
Enviada em: ter�a-feira, 5 de mar�o de 2002 10:54
Para: 'Martin Smith'; [EMAIL PROTECTED]
Assunto: RE: Is the JDBC Driver multi thread / servlet safe?
Hello,
in general the JDBC-driver is multi thread-safe. But you should not use the
same connection object in different threads at the same time, because only
some methods in the class ConnectionSapDB are synchronized. We don't
synchronize the whole connection object because of the costs for
synchronization. Normally a connection pool makes sure that only one
application can use the physical connection at a certain time. So, I don't
know why different threads should be use the same connection at the same
time.
Regards,
Marco
----------------------------------------------
Marco PASKAMP
SAP DB, SAP Labs Berlin
> -----Original Message-----
> From: Martin Smith [mailto:[EMAIL PROTECTED]]
> Sent: Dienstag, 5. M�rz 2002 13:56
> To: [EMAIL PROTECTED]
> Subject: Is the JDBC Driver multi thread / servlet safe?
>
>
> All,
>
> I am having problems with a multi threaded server application
> that uses
> a pool of connections that can be shared across threads. It appears
> that the sapDB JDBC driver connection is not thread safe. The
> symptoms
> are as follows. If I run a number of server processes I get
> database related
> errors that disappear if I synchronize the database access code on the
> connection being used to retrieve data. code snippet below.
>
> synchronized(connection) {
> resultSet = statement.executeQuery();
> while (resultSet.next()) {
> ...
> }
> }
>
> Am I correct in thinking that the Connection object
> is not thread safe ?
>
>
>
> Martin Smith
> Beansmith Technologies.
>
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.330 / Virus Database: 184 - Release Date: 28/02/02
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.330 / Virus Database: 184 - Release Date: 28/02/02
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general
