Mercurial > hg > LGServer
diff src/main/java/de/mpiwg/gazetteer/utils/DBService.java @ 5:5316e79f9a27
Implementation of search pagination and lazy loading to display the result set of a search.
author | "jurzua <jurzua@mpiwg-berlin.mpg.de>" |
---|---|
date | Mon, 16 Mar 2015 11:25:36 +0100 |
parents | 7682c04c63a8 |
children | 5610250d021a |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/gazetteer/utils/DBService.java Wed Mar 11 16:32:06 2015 +0100 +++ b/src/main/java/de/mpiwg/gazetteer/utils/DBService.java Mon Mar 16 11:25:36 2015 +0100 @@ -31,7 +31,18 @@ static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; static final String DB_URL = "jdbc:mysql://localhost/"; + /** + * This methods search from a list of terms. + * Every term is considered a subsequence of whole section name. + * + * @param termList + * @return + * @throws SQLException + */ public static List<DBSection> searchSection(List<String> termList) throws SQLException{ + + Long start = System.currentTimeMillis(); + List<DBSection> list = new ArrayList<DBSection>(); Connection conn = null; @@ -43,9 +54,9 @@ if(i>0){ query += " OR "; } - query += "name like '" + term + "%' "; + query += "name like '%" + term + "%' "; } - query += " limit 50"; + //query += " limit 50"; try { Class.forName(JDBC_DRIVER); @@ -55,8 +66,8 @@ ResultSet rs = stmt.executeQuery(query); while (rs.next()) { DBSection section = new DBSection(rs); - DBBook book = getBook0(conn, section.getBookId()); - section.setBook(book); + //DBBook book = getBook0(conn, section.getBookId()); + //section.setBook(book); list.add(section); } rs.close(); @@ -66,6 +77,9 @@ conn.close(); } + long end = System.currentTimeMillis(); + System.out.println("Time execution [ms]: " + (end - start)); + return list; }