It is not recommended to pass resultset as a parameter directly

Source: Internet
Author: User
It's going to be a lot of trouble, and it's been taking up a connection
Get ResultSet object, immediately put it into a ArrayList [] inside, after performing this method not only can turn off RS, and can be closed connection, the resources released, and then the array as a parameter passed on it, it has nothing to do with SQL

rs = st.executequery (SQL);
if (rs!=null) {
Rs.last ();
int rows = Rs.getrow ();
if (rows = = 0) return null;
Rs.beforefirst ();
Array = new Java.util.arraylist[rows];
int l = 0;
while (Rs.next ()) {
ARRAY[L] = new ArrayList ();
Array[l].add (0,rs.getstring (1));
Array[l].add (1,new Double (rs.getdouble (2)));
Array[l].add (2,new Double (rs.getdouble (3)));
Array[l].add (3,rs.getstring (4));
l++;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.