I sense some confusion here. You should not be asking about copies of methods but about copies of objects. Since your Vectors outData and inData are local variables in the doPost method, they are unique to a particular request and Thread. As long as none of these methods uses instance variables to manipulate data unique to a particular request, you are ok. It does not matter how many Threads are executing a method in a particular object, as long as only local variables are used, there will be no mixing of data. Bill

Joshua Doerring
Greenhorn

Joined: Aug 08, 2003
Posts: 19

posted Oct 14, 2003 08:52:00

0

I see what you're getting at. Yes I do have an instance variable of type DataSource and I use it to get a connection in the getStudentInfo() and getTeacherInfo() methods. Example: //... Connection connection = this.dataSource.getConnection("GSDQRSHARE", "GSDQRSHARE");

// Deactivate commitment control connection.setAutoCommit(true); //... So I should actually synchronize the use of this resource this this: //... Connection connection = null; synchronized(this.dataSource) { connection = this.dataSource.getConnection("GSDQRSHARE", "GSDQRSHARE"); } // Deactivate commitment control connection.setAutoCommit(true); //... Is this correct?

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 13004

5

posted Oct 15, 2003 08:31:00

0

If DataSource is an instance variable in your servlet, then you will need to synchronize access to it, yes. Having each request get its own connection is not very efficient, since opening a connection can be a slow process. You might want to investigate connection pooling. There are a number of implementations. Bill