luoyunpeng created TRAFODION-2685:
-------------------------------------

             Summary: using setString method to insert negative to integer 
column signed successfully
                 Key: TRAFODION-2685
                 URL: https://issues.apache.org/jira/browse/TRAFODION-2685
             Project: Apache Trafodion
          Issue Type: Bug
          Components: client-jdbc-t4
         Environment: cenot:6.7
            Reporter: luoyunpeng


using setString method to insert negative to integer column signed, result as 
following:
expect: {color:red}-2147483649{color}, but was: {color:red}2147483647{color}.
expect: {color:red}2147483648{color},  but was: {color:red}-2147483648{color}.

test code as following:
####
public void testSetString() throws SQLException {
                String tableName = "testsetString";

                try {
                        Statement stmt = conn.createStatement();
                        stmt.executeUpdate("create table " + tableName + " (id 
int not null,age int,primary key(id))");

                        stmt.executeUpdate("delete from " + tableName);
                        pstmt = conn.prepareStatement("insert into " + 
tableName + " values(?,?)");
                        pstmt.setInt(1, 1);
                        pstmt.setString(2, "-2147483649");
                        pstmt.executeUpdate();
                        
                        pstmt.setInt(1, 2);
                        pstmt.setString(2, "2147483648");
                        pstmt.executeUpdate();

                        ResultSet rs = stmt.executeQuery("select * from " + 
tableName);
                        rs.next();
                        System.out.println(rs.getString(2));
                        rs.next();
                        System.out.println(rs.getString(2));
                } finally {
                        dropTable(tableName);
                }

        }
####



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to