db connection bottleneck

from each db connection, i want to maximize the amout of data

extracted. currently

(machine #1): make db connection. read some data. create "object". send to machine #2.

(machine #2): receive "object".make a db connection, read some data.

i know the query that machine #2 will make before sending the object from machine #1.

i can't just have one ArrayList of values because different quries will have different # of columns with different types, (Double) or two columns (Double, String) or (Integer, Double, Double), etc. etc.

i can't serialize the db connection, so the data must be gotten on machine #1, then bundled-up for transmission over the socket.

what is a good solution?

PipedInputStream rcv_data =new PipedInputStream();

PipedOutputStream send_data =new PipedOutputStream(rcv_data);

LoadData loadData =new LoadData(send_data, query);

loadData.start();

ObjectInputStream rcv_data_ois =new ObjectInputStream(rcv_data);

while(loadData.isAlive()){

if(rcv_data.available() > 4){

String item = (String) rcv_data_ois.readObject();

String host = (String) ServerFinder.getServer();

Socket sok =new Socket(host, 5508);

ObjectOutputStream sok_oos =new ObjectOutputStream(sok.getOutputStream());

MyObj obj =new MyObj(item, query_made_on_machine2);

sok_oos.writeObject(obj);

}

.....

}// __while(loadData.isAlive())__

on machine #2, i start another

LoadData loadData =new LoadData(send_data, query_made_on_machine2);

loadData.start();

.....

thanks.

[2105 byte] By [dew2hirooa] at [2007-11-27 1:07:00]
# 1
if your code connect and disconnect from database repeatedly a connection pool might help.
LRMKa at 2007-7-11 23:42:12 > top of Java-index,Core,Core APIs...
# 2
i had never heard of "server pools"; they looklike exactly what i need.thanks for exanding my knowledge of java.
dew2hirooa at 2007-7-11 23:42:12 > top of Java-index,Core,Core APIs...
# 3
> > what is a good solution?>Do it all on box #2 would be a really good solution.Other than that cache the data.
jschella at 2007-7-11 23:42:12 > top of Java-index,Core,Core APIs...