Escolar Documentos
Profissional Documentos
Cultura Documentos
pstmt.setString(1,“IT-SOFT”) ;
pstmt.setLong(2, 41254) ;
pstmt.executeUpdate();
ResultSet Example:
z Contains all of the rows which satisfied the conditions ResultSet rs =
stmt.executeQuery("SELECT * FROM Customers");
in an SQL statement
z Provides access to the data in those rows through a while ( r.next() ) {
set of get methods
int i = r.getInt("customerid") ;
z The ResultSet.next method is used to move to the
String s = r.getString("companyname");
next row of the ResultSet, making the next row
float f = r.getFloat("discount_rate");
become the current row
System.out.println(“ROW = " + i + " " + s + " " +
z The general form of a result set is a table with column f);
headings and the corresponding values returned by a }
query
ResultSetMetaData
z Use to get information about the types and
properties of the columns in a ResultSet
object
z Created by the method getMetaData()
z Example:
ResultSet rs =
stmt.executeQuery("SELECT * FROM Customers");
ResultSetMetaData rsmd ;
rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();