Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Quick way to insert recordset in Arraylist?

843835May 3 2002 — edited May 6 2002
hi,

I am still trying to get the fastest method possible for inserting around 7000+ records
in an ArrayList.

Here are the options known to me:

1. Run an additional thread.
2. Open a small new browser window which handles the array in the 'background'.
3. Using a normal page calling a bean and displaying the arraylist results (too slow).

First of all I would like to know which would be the most quick and efficient.

I have also tried the "thread" route, but my code is giving problems.

My thread class looks like this:

import java.util.*;
import java.sql.*;

public class MyThread extends Thread {
private ArrayList Rows ;
private ArrayList Row ;
private String sql;
public Connection connect;


public MyThread(String sql,Connection conn) {
this.sql = sql;
this.connect = conn;
}

public void run()
{

try
{execSQL();
}
catch(Exception e)
{
}



}

public void execSQL() throws ClassNotFoundException,SQLException,Exception
{
Statement qrygetlabor = null;
ResultSet qrygetlaborrs = null;
ResultSetMetaData qrygetlaborrsmeta = null;

qrygetlabor = connect.createStatement();
qrygetlaborrs = qrygetlabor.executeQuery (sql);
qrygetlaborrsmeta = qrygetlaborrs.getMetaData();


if (qrygetlaborrs.next())
{


int rowcount = qrygetlaborrsmeta.getColumnCount();
do {
Row = new ArrayList();

for (int i = 1; i <= rowcount ; i++)
{
Row.add(qrygetlaborrs.getString(i));
}
Rows.add(Row);}
while (qrygetlaborrs.next());
}
}



public ArrayList getData()
{
return Rows;
}
}

and is called like this:

MyThread loader = new MyThread("select name from table order by name",conn);

unfortunately , I get a class error everytime:
E:\tomcat\work\localhost\_\testconn$jsp.java:146: Class org.apache.jsp.MyThread not found.



I have copied MyThread.class in every tomcat/JRE and JDK directory!

Maybe classpath?

Regards

Pierre
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2002
Added on May 3 2002
1 comment
291 views