Package com.sun.rowset

Examples of com.sun.rowset.JdbcRowSetImpl


      try
      {
         Class.forName( JDBC_DRIVER ); // load database driver class

         // specify properties of JdbcRowSet
         JdbcRowSet rowSet = new JdbcRowSetImpl()
         rowSet.setUrl( DATABASE_URL ); // set database URL
         rowSet.setUsername( USERNAME ); // set username
         rowSet.setPassword( PASSWORD ); // set password
         rowSet.setCommand( "SELECT * FROM authors" ); // set query
         rowSet.execute(); // execute query

         // process query results
         ResultSetMetaData metaData = rowSet.getMetaData();
         int numberOfColumns = metaData.getColumnCount();
         System.out.println( "Authors Table of Books Database:" );

         // display rowset header
         for ( int i = 1; i <= numberOfColumns; i++ )
            System.out.printf( "%-8s\t", metaData.getColumnName( i ) );
         System.out.println();
        
         // display each row
         while ( rowSet.next() )
         {
            for ( int i = 1; i <= numberOfColumns; i++ )
               System.out.printf( "%-8s\t", rowSet.getObject( i ) );
            System.out.println();
         } // end while
      } // end try
      catch ( SQLException sqlException )
      {
View Full Code Here

TOP

Related Classes of com.sun.rowset.JdbcRowSetImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.