Examples of QueryRunner


Examples of com.haulmont.yarg.util.db.QueryRunner

        String query = reportQuery.getScript();
        if (StringUtils.isBlank(query)) {
            return Collections.emptyList();
        }

        QueryRunner runner = new QueryRunner(dataSource);
        try {
            final QueryPack pack = prepareQuery(query, parentBand, params);

            ArrayList<Object> resultingParams = new ArrayList<Object>();
            QueryParameter[] queryParameters = pack.getParams();
            for (QueryParameter queryParameter : queryParameters) {
                if (queryParameter.isSingleValue()) {
                    resultingParams.add(queryParameter.getValue());
                } else {
                    resultingParams.addAll(queryParameter.getMultipleValues());
                }
            }

            resList = runner.query(pack.getQuery(), resultingParams.toArray(), new ResultSetHandler<List>() {
                @Override
                public List handle(ResultSet rs) throws SQLException {
                    List<Object[]> resList = new ArrayList<Object[]>();

                    while (rs.next()) {
View Full Code Here

Examples of com.iCo6.util.org.apache.commons.dbutils.QueryRunner

                    if(!Database.tableExists(Constants.Nodes.DatabaseTable.toString())) {
                        String SQL = Common.resourceToString("SQL/Core/Create-Table-" + Database.getType().toString().toLowerCase() + ".sql");
                        SQL = String.format(SQL, Constants.Nodes.DatabaseTable.getValue());

                        try {
                            QueryRunner run = new QueryRunner();
                            Connection c = iConomy.Database.getConnection();

                            try{
                                run.update(c, SQL);
                            } catch (SQLException ex) {
                                System.out.println("[iConomy] Error creating database: " + ex);
                            } finally {
                                DbUtils.close(c);
                            }
View Full Code Here

Examples of com.iCo6.util.org.apache.commons.dbutils.QueryRunner

                } catch (SQLException ex) {
                    System.out.println(ex);
                    return;
                }

                QueryRunner run = new QueryRunner();

                try {
                    try{
                        run.query(old, "SELECT * FROM " + table, new ResultSetHandler(){
                            public Object handle(ResultSet rs) throws SQLException {
                                Account current = null;
                                Boolean next = rs.next();

                                if(next)
View Full Code Here

Examples of com.iCo6.util.org.apache.commons.dbutils.QueryRunner

            return true;
        }

        try {
            QueryRunner run = new QueryRunner();
            Connection c = iConomy.Database.getConnection();

            try{
                String t = Constants.Nodes.DatabaseTable.toString();
                Integer amount = run.update(c, "INSERT INTO " + t + "(username, balance, status) values (?, ?, ?)", name.toLowerCase(), balance, status);

                if(amount > 0)
                    created = true;
            } catch (SQLException ex) {
                System.out.println("[iConomy] Error issueing SQL query: " + ex);
View Full Code Here

Examples of com.iCo6.util.org.apache.commons.dbutils.QueryRunner

            return false;
        }

        try {
            QueryRunner run = new QueryRunner();
            Connection c = iConomy.Database.getConnection();

            try{
                String t = Constants.Nodes.DatabaseTable.toString();
                Integer amount = run.update(c, "DELETE FROM " + t + " WHERE username=?", name.toLowerCase());

                if(amount > 0)
                    removed = true;
            } catch (SQLException ex) {
                System.out.println("[iConomy] Error issueing SQL query: " + ex);
View Full Code Here

Examples of com.iCo6.util.org.apache.commons.dbutils.QueryRunner

            return database.hasIndex(name);
        }

        try {
            QueryRunner run = new QueryRunner();
            Connection c = iConomy.Database.getConnection();

            try {
                String t = Constants.Nodes.DatabaseTable.toString();
                exists = run.query(c, "SELECT id FROM " + t + " WHERE username=?", returnBoolean, name.toLowerCase());
            } catch (SQLException ex) {
                System.out.println("[iConomy] Error issueing SQL query: " + ex);
            } finally {
                DbUtils.close(c);
            }
View Full Code Here

Examples of com.iCo6.util.org.apache.commons.dbutils.QueryRunner

            return balance;
        }

        try {
            QueryRunner run = new QueryRunner();
            Connection c = iConomy.Database.getConnection();

            try{
                String t = Constants.Nodes.DatabaseTable.toString();
                balance = run.query(c, "SELECT balance FROM " + t + " WHERE username=?", returnBalance, name.toLowerCase());
            } catch (SQLException ex) {
                System.out.println("[iConomy] Error issueing SQL query: " + ex);
            } finally {
                DbUtils.close(c);
            }
View Full Code Here

Examples of com.iCo6.util.org.apache.commons.dbutils.QueryRunner

            return;
        }

        try {
            QueryRunner run = new QueryRunner();
            Connection c = iConomy.Database.getConnection();

            try{
                String t = Constants.Nodes.DatabaseTable.toString();
                int update = run.update(c, "UPDATE " + t + " SET balance=? WHERE username=?", balance, name.toLowerCase());
            } catch (SQLException ex) {
                System.out.println("[iConomy] Error issueing SQL query: " + ex);
            } finally {
                DbUtils.close(c);
            }
View Full Code Here

Examples of com.iCo6.util.org.apache.commons.dbutils.QueryRunner

        if(!useInventoryDB() && !useMiniDB() && !useOrbDB())
            Thrun.init(new Runnable() {
                public void run() {
                    try {
                        QueryRunner run = new QueryRunner();
                        Connection c = iConomy.Database.getConnection();

                        try{
                            run.batch(c, query, parameters);
                        } catch (SQLException ex) {
                            System.out.println("[iConomy] Error with batching: " + ex);
                        } finally {
                            DbUtils.close(c);
                        }
View Full Code Here

Examples of com.iCo6.util.org.apache.commons.dbutils.QueryRunner

        }

        Thrun.init(new Runnable() {
            public void run() {
                try {
                    QueryRunner run = new QueryRunner();
                    Connection c = iConomy.Database.getConnection();

                    try {
                        String t = Constants.Nodes.DatabaseTable.toString();
                        Integer amount = run.update(c, "DELETE FROM " + t + " WHERE balance=?", Constants.Nodes.Balance.getDouble());
                    } catch (SQLException ex) {
                        System.out.println("[iConomy] Error issueing SQL query: " + ex);
                    } finally {
                        DbUtils.close(c);
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.