// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

public class FProblem {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost/Test", "root", "");
        Statement stmt = con.createStatement();
        stmt.executeUpdate("CREATE TABLE fproblem (x FLOAT(12,2) PRIMARY KEY, s VARCHAR(50))");
        PreparedStatement pstmt = con.prepareStatement("INSERT INTO fproblem VALUES(?,?)");
        pstmt.setFloat(1, 1000000000.0f);
        pstmt.setString(2, "1000000000.0f");
        pstmt.executeUpdate();
        pstmt = con.prepareStatement("SELECT * FROM fproblem WHERE x = ?");
        pstmt.setFloat(1, 1000000007.0f);
        ResultSet rs = pstmt.executeQuery();
        while(rs.next()) {
            System.out.println(rs.getFloat(1) + " " + rs.getString(2));
        }
        rs.close();
        stmt.executeUpdate("DROP TABLE fproblem");
        con.close();
    }
}
