import static org.junit.Assert.assertEquals;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.junit.Test;

public class TestNumeric {

    @Test
    public void JDBCNumeric() throws SQLException {
        Connection conn = null;
        Statement stmt = null;
        PreparedStatement prepStmt = null;
        ResultSet rs = null;
        String sql = "upsert using load into numeric_tbl values (?,?);";
        try {
            conn = Utils.getUserConnection();
            stmt = conn.createStatement();
            stmt.executeUpdate("set schema " + Utils.catalog + "." + Utils.schema);
            stmt.executeUpdate("create table if not exists numeric_tbl (c0 int not null, c1 numeric(20,0))");
            stmt.executeUpdate("delete from numeric_tbl");

            prepStmt = conn.prepareStatement(sql);
            for (int i = 0; i < 1000; i++) {
                prepStmt.setInt(1, i);
                prepStmt.setBigDecimal(2, new BigDecimal(-1));
                prepStmt.addBatch();
            }
            prepStmt.executeBatch();

            rs = stmt.executeQuery("select count(*) from numeric_tbl where c1=-1;");
            int result = 0;
            while (rs.next()) {
                result = rs.getInt(1);
            }
            rs.close();
            assertEquals("Rows returned count should be 1000", 1000, result);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            stmt.close();
            prepStmt.close();
            conn.close();
        }

    }
}


@@ -1,12 +1,878 @@
+/**%0A * @@@ START COPYRIGHT @@@%0A *%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *  http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied.  See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A *%0A * @@@ END COPYRIGHT @@%0A */%0A%0A
 import stati
@@ -2529,16 +2529,1422 @@
      %7D%0A%0A
+    %7D%0A    @Test%0A    public void JDBCNumeric2() throws SQLException %7B%0A        Connection conn = null;%0A        Statement stmt = null;%0A        PreparedStatement prepStmt = null;%0A        ResultSet rs = null;%0A        String sql = %22upsert using load into numeric_tbl2 values (?,?);%22;%0A        try %7B%0A            conn = Utils.getUserConnection();%0A            stmt = conn.createStatement();%0A            stmt.executeUpdate(%22set schema %22 + Utils.catalog + %22.%22 + Utils.schema);%0A            stmt.executeUpdate(%22create table if not exists numeric_tbl2 (c0 int not null, c1 numeric(10,2))%22);%0A            stmt.executeUpdate(%22delete from numeric_tbl2%22);%0A%0A            prepStmt = conn.prepareStatement(sql);%0A            for (int i = 0; i %3C 1000; i++) %7B%0A                prepStmt.setInt(1, i);%0A                prepStmt.setBigDecimal(2, new BigDecimal(-1));%0A                prepStmt.addBatch();%0A            %7D%0A            prepStmt.executeBatch();%0A%0A            rs = stmt.executeQuery(%22select count(*) from numeric_tbl2 where c1=-1;%22);%0A            int result = 0;%0A            while (rs.next()) %7B%0A                result = rs.getInt(1);%0A            %7D%0A            rs.close();%0A            assertEquals(%22Rows returned count should be 1000%22, 1000, result);%0A        %7D catch (SQLException e) %7B%0A            e.printStackTrace();%0A        %7D finally %7B%0A            stmt.close();%0A            prepStmt.close();%0A            conn.close();%0A        %7D%0A%0A
     %7D%0A%7D%0A

add copyright & one more test case