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 TypeMethodDescriptionbyte[]getBlob(int index) Gets column value by index.doublegetDouble(int index) Gets column value by index.floatgetFloat(int index) Gets column value by index.intgetInteger(int index) Gets column value by index.longgetLong(int index) Gets column value by index.shortgetShort(int index) Gets column value by index.getString(int index) Gets column value by index.
-
Method Details
-
getBlob
Gets column value by index.
Parameters
index: starts with zero
Returns
byte [] data
Throws
IOException
- Throws:
IOException
-
getDouble
Gets column value by index.
Parameters
index: starts with zero
Returns
a double data from the database
Throws
IOException
- Throws:
IOException
-
getFloat
Gets column value by index.
Parameters
index: starts with zero
Returns
a float data from the database
Throws
IOException
- Throws:
IOException
-
getInteger
Gets column value by index.
Parameters
index: starts with zero
Returns
a int data from the database
Throws
IOException
- Throws:
IOException
-
getLong
Gets column value by index.
Parameters
index: starts with zero
Returns
a long data from the database
Throws
IOException
- Throws:
IOException
-
getShort
Gets column value by index.
Parameters
index: starts with zero
Returns
a short data from the database
Throws
IOException
- Throws:
IOException
-
getString
Gets column value by index.
Parameters
index: starts with zero
Returns
a String data from the database
Throws
IOException
- Throws:
IOException
-