Bookmark Topic Watch Topic
  • New Topic

access database in java

 
Gaurav Singh Rana
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic