ResultSet clearWarnings Example
ResultSetclass clearWarnings example. This example shows you how to use clearWarnings method.
ResultSet class clearWarnings example. void clearWarnings() throws SQLException Clears all warnings reported on this ResultSet object. After this method is called, the method getWarnings returns null until a new warning is reported for this ResultSet object.
Here is the code
/*
* @ # ClearWarnings.java
* A class repersenting use to ClearWarnings method
* of ResultSet class in java.sql package
* version 23 June 2008
* author Rose India
*/
import java.sql.*;
public class ClearWarnings {
public static void main(String[] args) throws Exception {
Connection con = null;
Statement st = null;
ResultSet rs = null;
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://192.168.10.59:3306/";
String db = "Student";
Class.forName(driver);
con = DriverManager.getConnection(url + db, "root", "root");
try {
String sql = "Select * from stu_info";
st = con.createStatement();
rs = st.executeQuery(sql);
// Clears all warnings reported on this ResultSet object
rs.clearWarnings();
System.out.println("Clears all warnings reported "
+ "on this ResultSet object");
rs.first();
System.out.println("name " + rs.getString(2));
} catch (Exception e) {
System.out.println("SQL statement is not executed!");
System.out.println(e.toString());
}
}
} |
Output
Clears all warnings reported on this ResultSet object
name Mahendra
|
|