0

I am building a pie chart and a bar graph on the same page using JSF, and both conponents getting information from this query:

select 'ACCOUNTS'PRODUCT,sum(ACCT_BAL_LCY) AMOUNT from account_master where schm_type in(?, ?, ?,?) and ACCT_BAL_LCY >0 
union select 'BILLS'PRODUCT, sum(LIAB_AMT_LCY)AMOUNT from bills_details union select 'DOCUMENTARY CREDITS'PRODUCT,sum(LIAB_AMOUNT)AMOUNT 
from DC_DETAILS union select 'GUARANTEES'PRODUCT, sum(LIAB_AMT_LCY)AMOUNT from BG_DETAILS;

The method executing it is :

 private void createPieModel() {
        pieModel = new PieChartModel();
        categoryModel = new CartesianChartModel();
        ChartSeries act = new ChartSeries();
        act.setLabel("Product Types");
        Connection conn;
        db = new DBConnection();
        conn = db.getDbConnection();
        pr = new BiProperties();
        try {
            String sql = pr.getDBProperty().getProperty("liability.bank");
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1, "SBA");
            ps.setString(2, "CAA");
            ps.setString(3, "TDA");
            ps.setString(4, "CCA");
            ResultSet rs = ps.executeQuery();
            int i = 0;
            while (rs.next()) {
                pieModel.set(rs.getString(1), rs.getInt(2));
                act.set(rs.getString(1), rs.getInt(2));//Error on this Line
                cities.put(i, rs.getString(1));
                i++;

            }
            categoryModel.addSeries(act);

        } catch (SQLException asd) {
            log.debug(Level.FATAL, asd);
        }
    }

At times both Graphs Shows at, times none of the graphs show and at other times, only the Pie chart Show. On checking the Back end I am getting this error:

java.sql.SQLException: Numeric Overflow

How can I avoid this as it is happening randomly??

1

1 Answer 1

0

I suspect that it is thrown by aggregate functions in your SQL.
AFAIR by default SQL will define a variable to hold an aggregate function result to be the same type as the parameter of this function. You may want to redefine it as greater precision/size variables in your SQL.

Sign up to request clarification or add additional context in comments.

2 Comments

I havo no function except sum() in this sql, this is a plain select statement from the tables in question.
It applies to any aggregate functions if your column is defined as too small to hold the aggregated value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.