We suppose here that the Java program is limited to one class with just one main method.
Connect the database with the reader mode :
static public void main(String[] args) throws FatalException {
try {
ArgsParser ap = new ArgsParser(args);
Database.init(ap.getDBName());
} catch (SaadaException e1) {
FatalException.throwNewException(SaadaException.INTERNAL_ERROR, e1);
}
}
You can connect your SaadaDB in administrator mode with the statement below. In that case, the password must be added in the program parameters (-password=xxxxxx)
Database.getConnector().setAdminMode(ap.getPassword());
Run a query and get selected Java objects :
SaadaQLResultSet result = q.runQuery("Select ENTRY From * In * ");
while( result.next() ) {
long oid = result.getOid();
SaadaInstance si = Database.getCache().getObject(oid);
System.out.println(si.getNameSaada() + " " + si.getFieldValue("_logl") );
} last update 2008-10-30
|