当前位置: 首页>>代码示例>>Java>>正文


Java DruidPooledConnection.prepareStatement方法代码示例

本文整理汇总了Java中com.alibaba.druid.pool.DruidPooledConnection.prepareStatement方法的典型用法代码示例。如果您正苦于以下问题:Java DruidPooledConnection.prepareStatement方法的具体用法?Java DruidPooledConnection.prepareStatement怎么用?Java DruidPooledConnection.prepareStatement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.druid.pool.DruidPooledConnection的用法示例。


在下文中一共展示了DruidPooledConnection.prepareStatement方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertShop

import com.alibaba.druid.pool.DruidPooledConnection; //导入方法依赖的package包/类
@SneakyThrows
private static void insertShop(DruidPooledConnection connection, TcCrawlerShop shop) {
    try (PreparedStatement preparedStatement = connection.prepareStatement(
            "INSERT INTO it_shop("
                    + "id, "
                    + "name, "
                    + "location, "
                    + "describing_rate, "
                    + "service_rate, "
                    + "delivery_rate, "
                    + "comprehensive_rate, "
                    + "support_cod, "
                    + "support_online_pay, "
                    + "updated_person, "
                    + "updated_timestamp, "
                    + "created_person, "
                    + "created_timestamp"
                    + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
        preparedStatement.setString(1, shop.getId());
        preparedStatement.setString(2, shop.getName());
        preparedStatement.setString(3, PROVINCES[RandomUtils.nextInt(0, PROVINCES.length)]);
        preparedStatement.setInt(4, shop.getDescribingRate());
        preparedStatement.setInt(5, shop.getServiceRate());
        preparedStatement.setInt(6, shop.getDeliveryRate());
        preparedStatement.setInt(7, shop.getComprehensiveRate());
        preparedStatement.setString(8, RandomUtils.nextBoolean() ? "0" : "1");
        preparedStatement.setString(9, RandomUtils.nextBoolean() ? "0" : "1");
        preparedStatement.setString(10, TcBaseConsts.STR_32_0);
        preparedStatement.setString(11, "2016-12-31 12:12:12");
        preparedStatement.setString(12, TcBaseConsts.STR_32_0);
        preparedStatement.setString(13, "2016-12-31 12:12:12");
        preparedStatement.execute();
    }
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:35,代码来源:TcSaver.java

示例2: insertItem

import com.alibaba.druid.pool.DruidPooledConnection; //导入方法依赖的package包/类
@SneakyThrows
private static void insertItem(DruidPooledConnection connection, TcCrawlerItem item) {
    try (PreparedStatement preparedStatement = connection.prepareStatement(
            "INSERT INTO it_item("
                    + "id, "
                    + "shop_id, "
                    + "title, "
                    + "description, "
                    + "price, "
                    + "stock, "
                    + "sales_volume, "
                    + "fav_volume, "
                    + "comments_volue, "
                    + "delected, "
                    + "updated_person, "
                    + "updated_timestamp, "
                    + "created_person, "
                    + "created_timestamp"
                    + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
        preparedStatement.setString(1, item.getId());
        preparedStatement.setString(2, item.getShopId());
        preparedStatement.setString(3, item.getTitle());
        preparedStatement.setString(4, item.getDescription());
        preparedStatement.setLong(5, item.getPrice());
        preparedStatement.setInt(6, item.getStock());
        preparedStatement.setInt(7, RandomUtils.nextInt(10, 1500));
        preparedStatement.setInt(8, RandomUtils.nextInt(100, 15000));
        preparedStatement.setInt(9, RandomUtils.nextInt(5, 500));
        preparedStatement.setString(10, "0");
        preparedStatement.setString(11, TcBaseConsts.STR_32_0);
        preparedStatement.setString(12, "2016-12-31 12:12:12");
        preparedStatement.setString(13, TcBaseConsts.STR_32_0);
        preparedStatement.setString(14, "2016-12-31 12:12:12");
        preparedStatement.execute();
    }
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:37,代码来源:TcSaver.java

示例3: insertItemAttr

import com.alibaba.druid.pool.DruidPooledConnection; //导入方法依赖的package包/类
@SneakyThrows
private static void insertItemAttr(DruidPooledConnection connection, List<TcCrawlerItemAttr> attrs) {
    for (int i = 0; i < attrs.size(); i++) {
        TcCrawlerItemAttr attr = attrs.get(i);
        PreparedStatement preparedStatement = connection.prepareStatement(
                "INSERT INTO it_item_attr("
                        + "id, "
                        + "item_id, "
                        + "name, "
                        + "value, "
                        + "sequence, "
                        + "updated_person, "
                        + "updated_timestamp, "
                        + "created_person, "
                        + "created_timestamp"
                        + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
        preparedStatement.setString(1, attr.getId());
        preparedStatement.setString(2, attr.getItemId());
        preparedStatement.setString(3, attr.getName());
        preparedStatement.setString(4, attr.getValue());
        preparedStatement.setLong(5, attr.getSequence());
        preparedStatement.setString(6, TcBaseConsts.STR_32_0);
        preparedStatement.setString(7, "2016-12-31 12:12:12");
        preparedStatement.setString(8, TcBaseConsts.STR_32_0);
        preparedStatement.setString(9, "2016-12-31 12:12:12");
        preparedStatement.execute();
    }
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:29,代码来源:TcSaver.java

示例4: insertItemCover

import com.alibaba.druid.pool.DruidPooledConnection; //导入方法依赖的package包/类
@SneakyThrows
private static void insertItemCover(DruidPooledConnection connection, List<TcCrawlerItemCover> covers) {
    for (int i = 0; i < covers.size(); i++) {
        TcCrawlerItemCover cover = covers.get(i);
        try (PreparedStatement preparedStatement = connection.prepareStatement(
                "INSERT INTO it_item_cover("
                        + "id, "
                        + "item_id, "
                        + "cover, "
                        + "sequence, "
                        + "updated_person, "
                        + "updated_timestamp, "
                        + "created_person, "
                        + "created_timestamp"
                        + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?)")) {
            preparedStatement.setString(1, cover.getId());
            preparedStatement.setString(2, cover.getItemId());
            preparedStatement.setString(3, cover.getCover());
            preparedStatement.setLong(4, cover.getSequence());
            preparedStatement.setString(5, TcBaseConsts.STR_32_0);
            preparedStatement.setString(6, "2016-12-31 12:12:12");
            preparedStatement.setString(7, TcBaseConsts.STR_32_0);
            preparedStatement.setString(8, "2016-12-31 12:12:12");
            preparedStatement.execute();
        }
    }
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:28,代码来源:TcSaver.java

示例5: insertItemDetail

import com.alibaba.druid.pool.DruidPooledConnection; //导入方法依赖的package包/类
@SneakyThrows
private static void insertItemDetail(DruidPooledConnection connection, List<TcCrawlerItemDetail> details) {
    for (int i = 0; i < details.size(); i++) {
        TcCrawlerItemDetail detail = details.get(i);
        try (PreparedStatement preparedStatement = connection.prepareStatement(
                "INSERT INTO it_item_detail("
                        + "id, "
                        + "item_id, "
                        + "detail, "
                        + "sequence, "
                        + "updated_person, "
                        + "updated_timestamp, "
                        + "created_person, "
                        + "created_timestamp"
                        + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?)")) {
            preparedStatement.setString(1, detail.getId());
            preparedStatement.setString(2, detail.getItemId());
            preparedStatement.setString(3, detail.getDetail());
            preparedStatement.setLong(4, detail.getSequence());
            preparedStatement.setString(5, TcBaseConsts.STR_32_0);
            preparedStatement.setString(6, "2016-12-31 12:12:12");
            preparedStatement.setString(7, TcBaseConsts.STR_32_0);
            preparedStatement.setString(8, "2016-12-31 12:12:12");
            preparedStatement.execute();
        }
    }
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:28,代码来源:TcSaver.java

示例6: getMenuBySys

import com.alibaba.druid.pool.DruidPooledConnection; //导入方法依赖的package包/类
@Override
    public List<SysMenu> getMenuBySys(String sys) throws SQLException {

        String sql_select_funcgrp = "SELECT * FROM af_funcgrp WHERE type = 'leftMenu' AND status = 1 AND sys = ? ORDER BY disporder";
        String sq_select_func = "SELECT * FROM af_func WHERE grp_name = ? AND status = 1 ORDER BY disporder";

        DruidPooledConnection connection = druidDataSource.getConnection();
        PreparedStatement statement = connection.prepareStatement(sql_select_funcgrp);
        statement.setString(1, sys);
        ResultSet resultSet = statement.executeQuery();
        List<SysMenu> sysMenuList = new ArrayList<>();
        while (resultSet.next()){
            SysMenu sysMenu = new SysMenu();
            sysMenu.setMenu_name(resultSet.getString("namec"));
            sysMenu.setHref(resultSet.getString("plugin"));
            sysMenu.setIcon(resultSet.getString("icon"));

            PreparedStatement statement1 = connection.prepareStatement(sq_select_func);
            statement1.setString(1, resultSet.getString("name"));
            ResultSet resultSet1 = statement1.executeQuery();
            List<SysMenu.ChildMenu> childMenuList = new ArrayList<>();
            int i = 0;
            while (resultSet1.next()){
                SysMenu.ChildMenu childMenu = sysMenu.new ChildMenu();
                childMenu.setMenu_name(resultSet1.getString("namec"));
                childMenu.setHref(resultSet1.getString("plugin"));
//                childMenu.setIcon(resultSet1.getString("icon"));
                childMenuList.add(childMenu);
                i++;
            }
            statement1.close();
            //resultSet1.close();
            sysMenu.setChild_num(i);
            sysMenu.setChildes(childMenuList);
            sysMenuList.add(sysMenu);
        }
        connection.close();
        resultSet.close();      //  只需关闭一次
        statement.close();
        return sysMenuList;
    }
 
开发者ID:shuaijunlan,项目名称:Autumn-Framework,代码行数:42,代码来源:SysMapperImpl.java

示例7: getMenuByPage

import com.alibaba.druid.pool.DruidPooledConnection; //导入方法依赖的package包/类
@Override
    public List<VoMenu> getMenuByPage(int page, int limit, int level, String type, String sys) throws SQLException {
//        String sql_select_menu = "SELECT id, sys, name, state, disporder, type, level, parent_name";
//        String sql_select_menu = "SELECT id, sys, name, state, disporder, type, level, parent_name";
        String sql_select_menu = "SELECT * FROM ! WHERE type = ? AND sys = ? LIMIT " + (page - 1) * limit + "," + (page * limit);

        if (level == 1){
            sql_select_menu = sql_select_menu.replace("!", "af_funcgrp");
        }else if(level == 2){
            sql_select_menu = sql_select_menu.replace("!", "af_func");
        }
        DruidPooledConnection connection = druidDataSource.getConnection();
        PreparedStatement statement = connection.prepareStatement(sql_select_menu);
        statement.setString(1, type);
        statement.setString(2, sys);
        ResultSet resultSet = statement.executeQuery();
        List<VoMenu> voMenuList = new ArrayList<>();
        while(resultSet.next()){
            VoMenu voMenu = new VoMenu();
            voMenu.setId(resultSet.getInt("id"));
            voMenu.setDisporder(resultSet.getInt("disporder"));
            voMenu.setLevel(level + "级菜单");
            voMenu.setName(resultSet.getString("name"));
            voMenu.setNamee(resultSet.getString("namee"));
            voMenu.setNamec(resultSet.getString("namec"));
            voMenu.setSys(resultSet.getString("sys"));
            voMenu.setIcon(resultSet.getString("icon"));
            if (level == 1) {
                voMenu.setParent_name("");
            }
            else if (level == 2) {
                voMenu.setParent_name(resultSet.getString("grp_name"));
            }
            if (resultSet.getInt("status") == 0){
                voMenu.setStatus(BusinessConstants.SYS_MENU_STATUS_0.getMsg());
            }else if (resultSet.getInt("status") == 1){
                voMenu.setStatus(BusinessConstants.SYS_MENU_STATUS_1.getMsg());
            }
            voMenu.setType(type);
            voMenuList.add(voMenu);
        }

        resultSet.close();
        statement.close();
        connection.close();
        return voMenuList;
    }
 
开发者ID:shuaijunlan,项目名称:Autumn-Framework,代码行数:48,代码来源:MenuManageMapperImpl.java


注:本文中的com.alibaba.druid.pool.DruidPooledConnection.prepareStatement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。