1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.gwt.utgb.server.app;
26
27 import java.io.IOException;
28 import java.util.ArrayList;
29 import java.util.List;
30
31 import javax.servlet.ServletException;
32 import javax.servlet.http.HttpServletRequest;
33 import javax.servlet.http.HttpServletResponse;
34
35 import org.utgenome.UTGBException;
36 import org.utgenome.gwt.utgb.server.RequestHandlerBase;
37 import org.utgenome.gwt.utgb.server.UTGBMaster;
38 import org.xerial.db.DBException;
39 import org.xerial.db.sql.DatabaseAccess;
40 import org.xerial.util.StringUtil;
41 import org.xerial.util.log.Logger;
42
43
44
45
46
47
48
49 public class SQLiteAccessSample extends RequestHandlerBase {
50
51
52
53 private static final long serialVersionUID = 1L;
54
55 private static Logger _logger = Logger.getLogger(SQLiteAccessSample.class);
56
57 public void handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
58 ArrayList<String> speciesList = new ArrayList<String>();
59 try {
60
61 DatabaseAccess sqlite = UTGBMaster.getDatabaseAccess("legacy-track");
62 List<String> queryResult = sqlite.singleColumnQuery("select distinct species from tracks order by species", "species", String.class);
63 _logger.debug("species: " + queryResult);
64 speciesList.addAll(queryResult);
65
66 response.getWriter().println(StringUtil.join(queryResult, ", "));
67 }
68 catch (DBException e) {
69 _logger.error(e);
70 }
71 catch (UTGBException e) {
72 _logger.error(e);
73 }
74
75 }
76
77 }