Database query using Java

I was wondering if anybody out there has ever created a java service to query a remote database? I have a record structure as follows:


RL=Record List
T=Text Field

Is it possible to perform the following all within a java service?

a) read in the entire record list
b) loop over record list one
c) loop over record list two
d) now run a query using the value in T2
e) the result if returned mapped back into T2