Saving Data back to DB Takes Forever

Hi,

I've created a multithreaded application which reads in data from a Database A (on Sybase Server), performs number crunching on the data, and saves the data to Database B (on SQL Server). I'm using JTDS for the sql server and JConnect (Sybase Drivers) for the Sybase server. The problem is it takes forever to save the data. I think it's getting blocked somewhere but can't seem to figure out where. Here's is a stack dump of the thread which is saving the data:

Thread [Thread-9] (Suspended)

SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int) line: not available [native method]

SocketInputStream.read(byte[], int, int) line: not available

DataInputStream.readFully(byte[], int, int) line: not available

DataInputStream.readFully(byte[]) line: not available

SharedSocket.readPacket(byte[]) line: 841

SharedSocket.getNetPacket(int, byte[]) line: 722

ResponseStream.getPacket() line: 466

ResponseStream.read() line: 103

ResponseStream.peek() line: 88

TdsCore.wait(int) line: 3928

TdsCore.executeSQL(String, String, ParamInfo[], boolean, int, int, int, boolean) line: 1045

MSCursorResultSet.cursorCreate(String, String, ParamInfo[]) line: 536

MSCursorResultSet.<init>(JtdsStatement, String, String, ParamInfo[], int, int) line: 154

JtdsPreparedStatement(JtdsStatement).executeSQLQuery(String, String, ParamInfo[], boolean) line: 424

JtdsPreparedStatement.executeQuery() line: 777

CachedRowSetWriter.deleteOriginalRow(CachedRowSet, CachedRowSetImpl) line: not available

CachedRowSetWriter.writeData(RowSetInternal) line: not available

CachedRowSetImpl.acceptChanges() line: not available

CachedRowSetImpl.acceptChanges(Connection) line: not available

SaveData.saveToDB(PTConnection, CachedRowSet, String) line: 36

Data_3G(Module).run() line: 61

worker.run() line: 21

and here is a stack dump of a thread which is waiting on the save data (all other threads -- 10 threads in total -- are at this point:

Thread [Thread-1] (Suspended)

SaveData.saveToDB(PTConnection, CachedRowSet, String) line: 29

CDMAVoice(Module).run() line: 61

worker.run() line: 21

Thanks for the help!

[2284 byte] By [bce_developera] at [2007-11-27 10:51:37]
# 1

I tried running this again with 1 thread (main + thread1) and it still hangs at the same spot.

bce_developera at 2007-7-29 11:32:28 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Off hand, I doubt anyone knows a solution to this unique problem, not without actually looking at your code and how your doing threading (but you never know). Why do you need a multithreaded application? Why not one thread, open the first datasource, read in a pile of data into memory (not just one record), close the first datasource , process it, , open the other database and write it out. close that dataSource. Loop until all data is transfered. If all works ok, see if you can change the code to keep both datasources open at the same time before closing them.

I assume your using connection pooling throughout.

Again, off hand, I dont see a multithread application really speeding up the application much, my guess is that the bulk of the waiting is read/writing to the database and not processing. This is just a guess.

George123a at 2007-7-29 11:32:28 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...