Interface Row

All Known Subinterfaces:
RowExt

public interface Row

The Row interface is returned by com.codename1.db.Cursor#getRow() to provide access to the content of an individual row.

There is more thorough coverage of the Database API here.

The sample code below presents a Database Explorer tool that allows executing arbitrary SQL and viewing the tabular results:

Toolbar.setGlobalToolbar(true);
Style s = UIManager.getInstance().getComponentStyle("TitleCommand");
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_QUERY_BUILDER, s);
Form hi = new Form("SQL Explorer", new BorderLayout());
hi.getToolbar().addCommandToRightBar("", icon, (e) -> {
    TextArea query = new TextArea(3, 80);
    Command ok = new Command("Execute");
    Command cancel = new Command("Cancel");
    if(Dialog.show("Query", query, ok, cancel) == ok) {
        Database db = null;
        Cursor cur = null;
        try {
            db = Display.getInstance().openOrCreate("MyDB.db");
            if(query.getText().startsWith("select")) {
                cur = db.executeQuery(query.getText());
                int columns = cur.getColumnCount();
                hi.removeAll();
                if(columns > 0) {
                    boolean next = cur.next();
                    if(next) {
                        ArrayList data = new ArrayList<>();
                        String[] columnNames = new String[columns];
                        for(int iter = 0 ; iter

@author Chen
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    getBlob(int index)
    Gets column value by index.
    double
    getDouble(int index)
    Gets column value by index.
    float
    getFloat(int index)
    Gets column value by index.
    int
    getInteger(int index)
    Gets column value by index.
    long
    getLong(int index)
    Gets column value by index.
    short
    getShort(int index)
    Gets column value by index.
    getString(int index)
    Gets column value by index.
  • Method Details

    • getBlob

      byte[] getBlob(int index) throws IOException

      Gets column value by index.

      Parameters
      • index: starts with zero
      Returns

      byte [] data

      Throws
      • IOException
      Throws:
      IOException
    • getDouble

      double getDouble(int index) throws IOException

      Gets column value by index.

      Parameters
      • index: starts with zero
      Returns

      a double data from the database

      Throws
      • IOException
      Throws:
      IOException
    • getFloat

      float getFloat(int index) throws IOException

      Gets column value by index.

      Parameters
      • index: starts with zero
      Returns

      a float data from the database

      Throws
      • IOException
      Throws:
      IOException
    • getInteger

      int getInteger(int index) throws IOException

      Gets column value by index.

      Parameters
      • index: starts with zero
      Returns

      a int data from the database

      Throws
      • IOException
      Throws:
      IOException
    • getLong

      long getLong(int index) throws IOException

      Gets column value by index.

      Parameters
      • index: starts with zero
      Returns

      a long data from the database

      Throws
      • IOException
      Throws:
      IOException
    • getShort

      short getShort(int index) throws IOException

      Gets column value by index.

      Parameters
      • index: starts with zero
      Returns

      a short data from the database

      Throws
      • IOException
      Throws:
      IOException
    • getString

      String getString(int index) throws IOException

      Gets column value by index.

      Parameters
      • index: starts with zero
      Returns

      a String data from the database

      Throws
      • IOException
      Throws:
      IOException