protected static PreparedStatement prepareStatement(String query, Object... args) throws SQLException {
        String[] splitedQuery = (query + " ").split("\\?");
        int count = splitedQuery.length - 1;
        String resultQuery = "";
        List<Object> resultArgs = new ArrayList<Object>();
        if (count != args.length) {
            throw new SQLException("Invalid arguments count for query " + query + ". Expected " + count + " Actual " + args.length);
        } else {

            int counterArgiments = -1;
            String q;
            for (String queryPart : splitedQuery) {
                q = "?";
                if (counterArgiments == -1) {
                    resultQuery = queryPart;
                } else {
                    int counterList = 0;
                    if (args[counterArgiments] instanceof Collection) {
                        if (((Collection) args[counterArgiments]).isEmpty()) {
                            throw new SQLException("Invalid argument. Collection is Empty.");
                        }
                        for (Object object : (Collection) args[counterArgiments]) {
                            q = (counterList++ == 0 ? "" : q + ",") + "?";
                            resultArgs.add(object);
                        }
                    } else {
                        resultArgs.add(args[counterArgiments]);
                    }
                    resultQuery = resultQuery + q + queryPart;

                }
                counterArgiments++;
            }

            PreparedStatement statement = Query.getConnection().prepareStatement(resultQuery, Statement.RETURN_GENERATED_KEYS);
            if (!resultArgs.isEmpty()) {
                int index = 0;
                for (Object param : resultArgs) {
                    Query.processValue(statement, ++index, param);
                }
            }
            return statement;
        }
    }