aspose file tools
The moose likes JDBC and the fly likes access database in java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

access database in java

Gaurav Singh Rana
Greenhorn

Joined: Nov 21, 2008
Posts: 4
hi guys,
I am using a Java code to retrieve values from the Microsoft access database.My code is working fine but the thing is that code is taking 15 minutes to read 10000 rows of table which is really slow according to my professor.I have tried everything but i am not able to increase the speed of reading.So please help me in this regard ,I am posting the code below...



void dataread(String query)
{
int i=0,k=0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc dbc:SPRdb");
PreparedStatement prepStmnt = conn.prepareStatement(query);
PreparedStatement prepStmnt1 = conn.prepareStatement(query);
ResultSet rSet=prepStmnt.executeQuery();
ResultSet rSet1=prepStmnt1.executeQuery();
while(rSet1.next()){k++;}
rSet1.close();
itemid=new String[k];
ul =new double[k];
uw =new double[k];
uh =new double[k];
vol =new double[k];


while(rSet.next())
{
vol[i]=Double.parseDouble(rSet.getString(1));
itemid[i]=rSet.getString(4);
ul[i]=Double.parseDouble(rSet.getString(5));
uw[i]=Double.parseDouble(rSet.getString(6));
uh[i]=Double.parseDouble(rSet.getString(7));

i++;
}
rSet.close();
conn.close();

}
catch (Exception e) {}



}
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26218
    
  66

Please don't post the same question in multiple forums - it dilutes responses and wastes people's time. I'll close this copy for you.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: access database in java
 
Similar Threads
looping problem
JDBC issue with Oracle LONG datatype
JDBC-ODBC does not work for long datatypes using prepared statements
access database with java
how to update data of a field in one table from other table using jsp or java?