retrieiving rows!!!!!

HiWhich is better to use when retrieving rows from a database for processing (max 100 rows): Vectors or Array Lists?
[137 byte] By [seemac] at [2007-9-26 3:48:20]
# 1
Since you can know the size of your recordset, you can use an array...But as the syntax to read a recordset is likewhile(rs.next()){...You can use a Vector() instance. You'll avoid code lines.
sylvain.barbot at 2007-6-29 12:31:48 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
ArrayList gives you better performance than VectorSuresh
sureshkt at 2007-6-29 12:31:48 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

Hi,

The main difference is that all access to a Vector is synchronized, which is slower, but safer in a multi-threaded environment. If you are not using threads, or have protected your access in another way, ArrayList is a better choice.

Vector is part of Java 1.0 and 1.1, but ArrayList was only added in Java 1.2 and 1.3, so if you write code using ArrayList (or any of the collections API) you need at least a Java 1.2 VM.

Hope this will help you.

Anil

Developer Technical Support.

Sun Microsystems,India.

http://www.sun.com/developers/support

ramanil_indts at 2007-6-29 12:31:48 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...