Package SQLite

Interface Callback

All Known Implementing Classes:
Shell, TableResult, TableResultX

public interface Callback
Callback interface for SQLite's query results.

Example:
   class TableFmt implements SQLite.Callback {
     public void columns(String cols[]) {
       System.out.println("<TH><TR>");
       for (int i = 0; i < cols.length; i++) {
         System.out.println("<TD>" + cols[i] + "</TD>");
       }
       System.out.println("</TR></TH>");
     }
     public boolean newrow(String cols[]) {
       System.out.println("<TR>");
       for (int i = 0; i < cols.length; i++) {
         System.out.println("<TD>" + cols[i] + "</TD>");
       }
       System.out.println("</TR>");
       return false;
     }
   }
   ...
   SQLite.Database db = new SQLite.Database();
   db.open("db", 0);
   System.out.println("<TABLE>");
   db.exec("select * from TEST", new TableFmt());
   System.out.println("</TABLE>");
   ...
 
  • Method Summary

    Modifier and Type Method Description
    void columns​(String[] coldata)
    Reports column names of the query result.
    boolean newrow​(String[] rowdata)
    Reports row data of the query result.
    void types​(String[] types)
    Reports type names of the columns of the query result.
  • Method Details

    • columns

      void columns​(String[] coldata)
      Reports column names of the query result. This method is invoked first (and once) when the SQLite engine returns the result set.

      Parameters:
      coldata - string array holding the column names
    • types

      void types​(String[] types)
      Reports type names of the columns of the query result. This is available from SQLite 2.6.0 on and needs the PRAGMA show_datatypes to be turned on.

      Parameters:
      types - string array holding column types
    • newrow

      boolean newrow​(String[] rowdata)
      Reports row data of the query result. This method is invoked for each row of the result set. If true is returned the running SQLite query is aborted.

      Parameters:
      rowdata - string array holding the column values of the row