Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

unable to build project

a.stoyanovMay 16 2013 — edited May 17 2013
Hi all,
I'm using Netbeans IDE 7.3. When i tried to clean and build my project i received the following error:
Note: D:\work\netbeans\snejana_bah\src\myFinance\Categories.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
This class worked fine yesterday and no changes made... Any ideas?

Here is the source:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package myFinance;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;

/**
 *
 * @author Sasho
 */
public class Categories {

//    String host = "jdbc:derby:D:\\sasho\\java_work\\work\\SnejanaBah\\snejana_bah;create=true";
    String host = "jdbc:derby:release\\snejana_bah";
    String uName = "fester";
    String uPass = "fester";
    ResultSet res = null;
    String month = null;
    final DefaultComboBoxModel<DefaultComboBoxModel> model = new DefaultComboBoxModel<DefaultComboBoxModel>(); 
    String[] comboBoxArray;
    Double limit = 0.0;
    String index;
    
    public String getMonth(Integer mon) {

        switch (mon) {
            case 0:
                month = "Януари";
                break;
            case 1:
                month = "Февруари";
                break;
            case 2:
                month = "Март";
                break;
            case 3:
                month = "Април";
                break;
            case 4:
                month = "Май";
                break;
            case 5:
                month = "Юни";
                break;
            case 6:
                month = "Юли";
                break;
            case 7:
                month = "Август";
                break;
            case 8:
                month = "Септември";
                break;
            case 9:
                month = "Октомври";
                break;
            case 10:
                month = "Ноември";
                break;
            case 11:
                month = "Декември";
                break;


        }


        return month;
    }

    public int getMonthInt(String mon) {
        int montInt = 0;
        switch (mon) {
            case "Януари":
                montInt = 0;
                break;
            case "Февруари":
                montInt = 1;
                break;
            case "Март":
                montInt = 2;
                break;
            case "Април":
                montInt = 3;
                break;
            case "Май":
                montInt = 4;
                break;
            case "Юни":
                montInt = 5;
                break;
            case "Юли":
                montInt = 6;
                break;
            case "Август":
                montInt = 7;
                break;
            case "Септември":
                montInt = 8;
                break;
            case "Октомври":
                montInt = 9;
                break;
            case "Ноември":
                montInt = 10;
                break;
            case "Декември":
                montInt = 11;
                break;


        }


        return montInt;
    }

    public ResultSet getLimits(Integer year, String month, Boolean check) {



        try {

            Connection con = DriverManager.getConnection(host, uName, uPass);
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

            if (check) {
                PreparedStatement ps = con.prepareStatement("select l.ID, "
                        + "c.CATEGORY_NAME as Категория, "
                        + "l.LIMIT_YEAR as Година,"
                        + " l.\"MONTH\" as Месец, "
                        + "l.\"LIMIT\" as Лимит "
                        + "from FESTER.LIMITS l , "
                        + "fester.CATEGORIES c\n"
                        + "where l.CAT_ID = c.ID "
                        + "and l.limit_year = ? "
                        + "order by c.CATEGORY_NAME, l.\"MONTH\"");


                ps.setInt(1, year);


                res = ps.executeQuery();
            } else {
                PreparedStatement ps = con.prepareStatement("select l.ID, "
                        + "c.CATEGORY_NAME as Категория, "
                        + "l.LIMIT_YEAR as Година,"
                        + " l.\"MONTH\" as Месец, "
                        + "l.\"LIMIT\" as Лимит "
                        + "from FESTER.LIMITS l , "
                        + "fester.CATEGORIES c\n"
                        + "where l.CAT_ID = c.ID "
                        + "and l.limit_year = ? "
                        + "and l.month = ? "
                        + "order by c.CATEGORY_NAME, l.\"MONTH\"");


                ps.setInt(1, year);
                ps.setString(2, month);


                res = ps.executeQuery();
            }

        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(Reports.class.getName()).log(Level.SEVERE, null, ex);
        }


        return res;
    }

    public void insertLimit(Integer cat_id, Integer year, String month, Double limit) {
        try {

            Connection con = DriverManager.getConnection(host, uName, uPass);
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");


            PreparedStatement stmt = con.prepareStatement("select max(id) + 1 as id from FESTER.LIMITS");

            ResultSet rs = stmt.executeQuery();
            Integer id = null;
            while (rs.next()) {
                id = rs.getInt("ID");
            }

            PreparedStatement ps = con.prepareStatement("insert into FESTER.LIMITS \n"
                    + "values(?,?,?,?,?)");

            ps.setInt(1, id);
            ps.setInt(2, cat_id);
            ps.setInt(3, year);
            ps.setString(4, month);
            ps.setDouble(5, limit);


            ps.executeUpdate();








        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(Reports.class
                    .getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void updateLimit(Integer id, Integer year, String month, Double limit) {

        try {

            Connection con = DriverManager.getConnection(host, uName, uPass);
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");



            PreparedStatement ps = con.prepareStatement("update fester.limits t "
                    + "set t.limit_year = ?, t.month = ?, t.limit = ? "
                    + "where t.id = ?");

            ps.setInt(1, year);
            ps.setString(2, month);
            ps.setDouble(3, limit);
            ps.setInt(4, id);


            ps.executeUpdate();

        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(Reports.class
                    .getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void insertCategory(String catName, Integer type, String Desc) {

        try {
            Integer id = 0;

            Connection con = DriverManager.getConnection(host, uName, uPass);
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

            PreparedStatement st = con.prepareStatement("select max(id) + 1 as id from fester.categories");

            ResultSet rs = st.executeQuery();

            while (rs.next()) {
                id = rs.getInt("ID");
            }

            PreparedStatement ps = con.prepareStatement("insert into fester.categories values(?,?,?,?)");

            ps.setInt(1, id);
            ps.setString(2, catName);
            ps.setString(3, Desc);
            ps.setInt(4, type);



            ps.executeUpdate();

        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(Reports.class
                    .getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void fillCombobox(JComboBox box) {

        try {


            Connection con = DriverManager.getConnection(host, uName, uPass);
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");


            PreparedStatement ps = con.prepareStatement("select category_name from fester.categories where id <> 0 group by category_name");


            ResultSet rs = ps.executeQuery();


            while (rs.next()) {

                box.addItem(rs.getObject(1));
            }



        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(Reports.class
                    .getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void fillComboboxDebit(JComboBox box) {

        try {


            Connection con = DriverManager.getConnection(host, uName, uPass);
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");


            PreparedStatement ps = con.prepareStatement("select category_name from fester.categories where id <> 0 "
                    + "and trx_type = 1 "
                    + "group by category_name");


            ResultSet rs = ps.executeQuery();


            while (rs.next()) {

                box.addItem(rs.getObject(1));
            }



        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(Reports.class
                    .getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void fillComboboxCredit(JComboBox box) {

        try {


            Connection con = DriverManager.getConnection(host, uName, uPass);
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");


            PreparedStatement ps = con.prepareStatement("select category_name from fester.categories where id <> 0 "
                    + "and trx_type = 0 "
                    + "group by category_name");


            ResultSet rs = ps.executeQuery();


            while (rs.next()) {

                box.addItem(rs.getObject(1));
            }



        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(Reports.class
                    .getName()).log(Level.SEVERE, null, ex);
        }

    }

    public Double getCurrentLimit(Integer catId, String month) {
        try {


            Connection con = DriverManager.getConnection(host, uName, uPass);
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");


            PreparedStatement ps = con.prepareStatement("select limit from fester.limits where cat_id = ? and month = ?");

            ps.setInt(1, catId);
            ps.setString(2, month);
            ResultSet rs = ps.executeQuery();


            while (rs.next()) {
                limit = rs.getDouble("limit");
            }



        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(Reports.class
                    .getName()).log(Level.SEVERE, null, ex);
        }
        return limit;

    }

    public Double getTotal(int month, Integer year, Integer catId) {
        try {


            Connection con = DriverManager.getConnection(host, uName, uPass);
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");


            PreparedStatement ps = con.prepareStatement("select sum(t.AMOUNT) as amnt from fester.TRANSACTIONS t \n"
                    + "where month(t.DATE_CREATED) = ?\n"
                    + "and year(t.DATE_CREATED) = ?\n"
                    + "and t.CATEGORY = ?  ");


            ps.setInt(1, month);
            ps.setInt(2, year);
            ps.setInt(3, catId);
            ResultSet rs = ps.executeQuery();


            while (rs.next()) {
                limit = rs.getDouble("amnt");
            }



        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(Reports.class
                    .getName()).log(Level.SEVERE, null, ex);
        }
        return limit;

    }

    public String getLimitIndex(Double total, Double limit) {



        if (total > limit) {
            index = "Отрицателен";
        } else {
            index = "Положителен";
        }

        return index;

}
Thanks in advance,
Alexander.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 14 2013
Added on May 16 2013
9 comments
531 views