Is that OK to store query Result in String 2 Dimension ?

Is that OK to store the result of query in String 2 dimension ?

im a litle bit confuse about the return value of this method. If i user ResultSet, the ResultSet need to be close. But if the ResultSet is closed, i cannot read data. So i think maybe i should use the String[][]. Is thar ok if it use for high scale application ?

public String[][] selectQuery(String query)throws SQLException

{

recordset=new String[10][30];

Statement select=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

rs=select.executeQuery(query);

rsmd=rs.getMetaData();

z=0;

while(rs.next())

{

for(int i=1;i<=rsmd.getColumnCount();i++)

{

recordset[i][z]=rs.getString(i);

}

z++;

}

rs.close();

select.close();

return

recordset;

}

[1256 byte] By [MyPermanaa] at [2007-11-27 11:22:36]
# 1

If you want to convert *all* data types (integer, double, decimal, bytearray, blobs, dates, etc) to String, it's your choice.

I'd rather used a collection of DTO's.

BalusCa at 2007-7-29 14:55:49 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

collection of DTO's ? what is it? i never use it.

Could you give me an example?

Btw, what a fast response ...

MyPermanaa at 2007-7-29 14:55:49 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

java.util.Collection<DTO>

A Collection can be a List or Set. A DTO is a POJO intented for transferring of data between the tiers.

BalusCa at 2007-7-29 14:55:49 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

coolection of Dto's ?

never use it before. Could you give me an example ?

MyPermanaa at 2007-7-29 14:55:49 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

Here are some useful links:

Collection tutorial: http://java.sun.com/docs/books/tutorial/collections/index.html

DTO's definied: http://en.wikipedia.org/wiki/Data_Transfer_Object

BalusCa at 2007-7-29 14:55:49 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

Sorry for the double quotes, that because my browser get blank so i refresh it for many times.

Vector is Collection too right? which way is fastest ? using string or collection ? im thinkking about using Map and Vector.

MyPermanaa at 2007-7-29 14:55:49 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...