jdbc and multiple thread

hi, i have an application that creates multiple thread..each thread (querythread) is accessing a webservice(querydb) that retrieves data from different databases. This webservice supposed to create a jdbc connection each time it is invoke by the querythread. The problem is i get an error that a particular table does not exist in the server..This is cause by the confusion in my program..

The table is access in the wrong server..e.g.(cdsisis.TblHoldings does not exist) this is because thread is confuse and using a different connection..when i tried to use the querydb webservice directly per database it is ok. but when i try to make multiple thread to invoke querydb accessing different database it has this error: cdsisis.TblHoldings does not exist

cdsisis is a database server..and tblHoldings is a table in another database named silms. i think the thread tends to share resources.

should it be that thread supposed to be independent with each other? how come this is happening?

[1011 byte] By [rinoa_fftsya] at [2007-11-27 10:48:23]
# 1

Java Threads are lightweight, meaning they share the same address space. Make sure you aren't using the same variable for both connections.

Dalzhima at 2007-7-28 22:26:24 > top of Java-index,Core,Core APIs...
# 2

it has same variable Connection conn in querydb class which was invoke by each instance of querythread. what should i do so that connection to different database will not have conflict?

rinoa_fftsya at 2007-7-28 22:26:24 > top of Java-index,Core,Core APIs...
# 3

Make sure that each Thread uses a different instance of the QueryDb class, or use 2 different Connection variables.

Dalzhima at 2007-7-28 22:26:24 > top of Java-index,Core,Core APIs...
# 4

yes i have a different instance of querydb webservice in querythread..because every time a new querythread is created, a new querydb instance is also created within the querythread. still this problem occurs.

rinoa_fftsya at 2007-7-28 22:26:24 > top of Java-index,Core,Core APIs...
# 5

> Java Threads are lightweight, meaning they share the same address space.

All thread implementations do that: that's what a thread means.

Java threads are lightweight because they don't use native threads.

ejpa at 2007-7-28 22:26:24 > top of Java-index,Core,Core APIs...
# 6

you mean even if i invoke new querythread..the member objects of querythread is shared by all the instance of querythread?

rinoa_fftsya at 2007-7-28 22:26:24 > top of Java-index,Core,Core APIs...
# 7

No.

ejpa at 2007-7-28 22:26:24 > top of Java-index,Core,Core APIs...