21.05.2014 Views

Android & PostgreSQL (application/pdf - 311.5 KB) - PGCon

Android & PostgreSQL (application/pdf - 311.5 KB) - PGCon

Android & PostgreSQL (application/pdf - 311.5 KB) - PGCon

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Execute a Query<br />

Select the name of all relations from pg class and iterate through every row<br />

returned:<br />

S t r i n g s q l ;<br />

s q l = ”SELECT relname FROM p g c l a s s WHERE r e l k i n d = ’ r ’ ; ”<br />

Statement s t = conn . c r e a t e S t a t e m e n t ( ) ;<br />

R e s u l t S e t r s = s t . executeQuery ( s q l ) ;<br />

while ( r s . next ( ) ) {<br />

// Columns a r e can be r e f e r e n c e d by name .<br />

S t r i n g relname = r s . g e t S t r i n g ( ” relname ” ) ;<br />

}<br />

r s . c l o s e ( ) ;<br />

s t . c l o s e ( ) ;<br />

markwkm (<strong>PGCon</strong>2011) <strong>Android</strong> & <strong>PostgreSQL</strong> 20 May 2011 11 / 37

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!