Java tutorial
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.Statement; public class Main { public static void main(String[] args) throws Exception { // Get warnings on ResultSet object ResultSet rs = null; Connection conn = null; Statement stmt = null; try { conn = getConnection(); // get a java.sql.Connection object stmt = conn.createStatement(); // create a statement // get a result set String sqlQuery = "select id, name from employees"; rs = stmt.executeQuery(sqlQuery); while (rs.next()) { // use result set // // get warnings on the current row of the ResultSet object SQLWarning warning = rs.getWarnings(); if (warning != null) { // process result set warnings } } } catch (SQLException e) { // ignore the exception } finally { // close JDBC resources: ResultSet, Statement, Connection } } private static Connection getConnection() throws Exception { Class.forName("org.hsqldb.jdbcDriver"); String url = "jdbc:hsqldb:mem:data/tutorial"; return DriverManager.getConnection(url, "sa", ""); } }