KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ashkelon > db > IndexQueryTest


1 /*
2  * Created on Aug 19, 2004
3  */

4 package org.ashkelon.db;
5
6 import java.sql.*;
7 import java.util.Date JavaDoc;
8
9 /**
10  * @author Eitan Suez
11  */

12 public class IndexQueryTest
13 {
14    private static int FETCH_SIZE = 20;
15    
16    public static void main(String JavaDoc[] args) throws Exception JavaDoc
17    {
18       String JavaDoc query =
19          " select " +
20          " m.id, m.qualifiedname, m.type, m.isstatic, " +
21          " m.isfinal, m.accessibility, m.modifier, meth.isabstract, " +
22          " meth.returntypeid, meth.returntypename, meth.returntypedimension, " +
23          " em.signature, d.summarydescription, d.since, d.deprecated " +
24          " from METHOD meth right outer join MEMBER m on meth.id=m.id " +
25          " left outer join EXECMEMBER em on em.id=m.id, DOC d " +
26          " where m.docid = d.id order by m.name";
27       
28       Connection conn = DBMgr.getInstance().getConnection();
29       PreparedStatement p = conn.prepareStatement(query,
30             ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
31       p.setFetchSize(FETCH_SIZE);
32       
33       java.util.Date JavaDoc start = new java.util.Date JavaDoc();
34       ResultSet rset = p.executeQuery();
35       long millis = new Date JavaDoc().getTime() - start.getTime();
36       int secs = (int) (millis / 1000);
37       System.out.println("query execution time: "+secs+" seconds");
38       //System.out.println("query execution took: "+millis+" ms");
39

40       rset.close();
41       /*
42       int i=1;
43       while (rset.next())
44       {
45          System.out.println(i+". " + rset.getString(2));
46          i++;
47       }
48       */

49    }
50    
51 }
52
Popular Tags