import java.sql.Connection; import java.sql.DriverManager;  import java.sql.Statement;
import java.sql.ResultSet;  import java.io.FileInputStream; import java.util.Properties;
public class JdbcSequenceOracle {
 public static void main(String[] args){
  try {  Properties props = new Properties();
  props.load(new FileInputStream("conn.props"));
  Connection con = DriverManager.getConnection(props.getProperty("url"), props);
  String sql = "DECLARE s varchar2(20);" +
     "BEGIN SELECT name INTO s FROM continent WHERE name='Asia'; " +
     "DELETE FROM continent; UPDATE country SET population=80000000 WHERE code='D'; END;";
   Statement stmt = con.createStatement();
   boolean hasMoreResultSets = stmt.execute(sql);
   while ( hasMoreResultSets || stmt.getUpdateCount() != -1 ) {
     if ( hasMoreResultSets ) { // if has rs
         ResultSet rs = stmt.getResultSet();
         int size = 0; while (rs.next()) { size++; }
         System.out.println("Result set size: " + size); }
     else { // if ddl/dml/...
       int queryResult = stmt.getUpdateCount();
       System.out.println(queryResult + " tuples updated");
     } // check whether to continue in the loop:
     hasMoreResultSets = stmt.getMoreResults();  }
   stmt.close(); con.close();
  } catch (Exception e) { e.printStackTrace(); } } }
