saada logo

 
  SAADA OVERVIEW
Home  
News  
Tutos and Links  
Download  
  Tutorial
Getting started  
Doing More  
SaadaQL  
The Web Interface  
VO Publishing  
Tips & Troubelshooting  
  COMMUNITY
Mailing List  
Saada Sites  
How to Contact us ?  
  DEVELOPER CORNER
Contributors  
Next Step  
Old Releases  
Inside Saada  
Using UWS  

 

SourceForge.net Logo


HOME ART > Tutorial > Doing More > Using the Saada API
Using the Java API



 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