/* * MyTest.java * * Created on 2006. lipanj 14, 11:43 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package bug18401; /** * * @author Tonci */ import com.mysql.jdbc.util.BaseBugReport; import java.sql.Connection; import java.util.Properties; import java.sql.*; import java.util.ArrayList; import java.util.logging.*; import junit.framework.Assert; public class MyTest extends BaseBugReport { private static final Properties properties = new Properties(); { properties.put("user","root"); properties.put("password",""); properties.put("autoReconnect","true"); //properties.put("characterEncoding","UTF-8"); //properties.put("characterSetResults","UTF-8"); //properties.put("connectionCollation","utf8_slovenian_ci"); //String jdbcUrl = "jdbc:mysql://munja/test"; //String username = "root"; //String password = ""; //Connection conn = DriverManager.getConnection( jdbcUrl, username, password ); } public MyTest() { } public void runTest() throws Exception { Logger.getLogger(this.getClass().toString()).entering("runTest",""); Connection conn = getConnection("jdbc:mysql://munja:3307/test", properties); //getUrl() PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM test_bind_fetch"); Statement stmt = conn.createStatement(); ResultSet rs2 = pstmt.executeQuery(); ResultSet rs = stmt.executeQuery("SELECT * FROM test_bind_fetch"); Logger.getLogger(this.getClass().toString()).log(Level.INFO, "SELECT * FROM test_bind_fetch returned "+rs.getWarnings()+ " warning(s)"); assertTrue(rs.next() && rs2.next()); //OK Assert.assertEquals(3.1415926535F, rs2.getFloat(1), 0F); //FAILS Assert.assertEquals(rs.getFloat(1), rs2.getFloat(1), 0F); rs.close(); rs2.close(); pstmt.close(); } /** * Override this method with code that sets up the testcase for * demonstrating your bug (creating tables, populating data, etc). * * @throws Exception if an error occurs during the 'setUp' phase. */ public void setUp() throws Exception { Logger.getLogger(this.getClass().toString()).entering("setUp",""); Connection conn = getConnection("jdbc:mysql://munja:3307/test", properties); //getUrl() Statement stmt = conn.createStatement(); stmt.execute("SET sql_mode=''"); stmt.execute("USE test"); stmt.executeUpdate("DROP TABLE IF EXISTS test_bind_fetch"); stmt.executeUpdate("CREATE TABLE test_bind_fetch(c1 float(24), "+ "c2 float, c3 float unsigned, c4 float,c5 float,c6 float, c7 float(10) unsigned)"); stmt.close(); stmt = conn.createStatement(); stmt.executeUpdate("INSERT INTO test_bind_fetch (c1,c2,c3,c4,c5,c6,c7) "+ "VALUES (3.1415926535,-0.000001, 0, 999999999999, sin(0.6),1.00000000000001, 888888888888888)"); stmt.close(); conn.close(); } /** * Override this method with code that cleans up anything created in the * setUp() method. * * @throws Exception if an error occurs during the 'tearDown' phase. */ public void tearDown() throws Exception { Logger.getLogger(this.getClass().toString()).entering("tearDown",""); Connection conn = getConnection("jdbc:mysql://munja:3307/test", properties); //getUrl() Statement stmnt = conn.createStatement(); stmnt.execute("DROP TABLE IF EXISTS test_bind_fetch"); conn.close(); } /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here MyTest MyTest = new MyTest(); try { MyTest.setUp(); try { MyTest.runTest(); } catch (Exception ex) { ex.printStackTrace(); } MyTest.tearDown(); } catch (Exception ex) { ex.printStackTrace(); } } }