Author
access database in java
Gaurav Singh Rana
Greenhorn
Joined: Nov 21, 2008
Posts: 4
posted Nov 21, 2008 14:51:00
0
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
posted Nov 21, 2008 20:22:00
0
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
subject: access database in java