O'Reilly - Java Database Programming with JDBC.pdf - Google Drive

2 downloads 148 Views 3MB Size Report
Oct 1, 1996 - O'Reilly - Java Database Programming with JDBC.pdf. O'Reilly - Java Database Programming with JDBC.pdf. Op
Java ; Name = "pratik"; password = ""; Connection con; con = DriverManager.getConnection(url, Name, password); // remember to register the driver before doing this!

Chapter 4 shows a complete example of how to use the DriverManager and Connection classes, as well as how to execute queries against the ; int columns; int pos; try { // Several of the following methods can throw exceptions if there was a // problem with the query, or if the connection breaks, or if // we improperly try to retrieve results. // // // // //

Statement stmt = con.createStatement(); First, we instantiate a Statement class that is required to execute the query. The Connection class returns a Statement object in its createStatement method, which links the opened connection to the passed-back Statement object. This is how the stmt instance is linked to the actual connection to the ; // For each row that we fetch, we need to add a carriage return so that // the next fetched row starts on the next line. } // End while loop ( end fetching rows when no more rows are left ). stmt.close(); // Clean up, close the stmt, in effect, close the input-output query // connection streams, but stay connected to the ; } more=rs.next(); // Get the first row of the ResultSet. Loop through the ResultSet // and get the ; // The URL for the ; } more=rs.next(); while(more) { for (pos=1; pos