Native UltraLite for Java User's Guide
Understanding UltraLite Development
Accessing and manipulating data with dynamic SQL
Use the SELECT statement to retrieve information from the database.
To execute a SELECT query using ExecuteQuery:
Create a new prepared statement and result set.
PreparedStatement prepStmt;
Assign a prepared statement to your newly created PreparedStatement object.
prepStmt = conn.prepareStatement( "SELECT MyColumn FROM MyTable");
Execute the statement.
In the following code, the result of the SELECT query contain a string, which is output to a command prompt.
ResultSet customerNames = prepStmt.executeQuery();
customerNames.moveBeforeFirst();
while( customerNames.moveNext() ) {
for ( int i = 1;
i <= customerNames.schema.getColumnCount();
i++ ) {
System.out.print(
customerNames.getString( i ) + " "
);
System.out.println();
}
}