//
// For test, create table with:
//
//   CREATE TABLE sample(foo INT PRIMARY KEY NOT NULL, bar INT);
//   INSERT INTO sample values (1, 10);
//   INSERT INTO sample values (2, 20);
//   INSERT INTO sample values (3, 30);
//

import java.sql.*;

public class SqlTest {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver").newInstance();

        Connection db = DriverManager.getConnection(
            "jdbc:mysql://localhost/test", "tai", "hogehoge");

        //
        // Test if prepared statement fails as reported by #564961
        //
        PreparedStatement st = db.prepareStatement("SELECT * from sample");
        ResultSet rs = st.executeQuery();
        while (rs.next()) {
            System.out.println(rs.getString("foo") + rs.getString("bar"));
        }
        rs.close();
        st.close();
        db.close();
    }
}
