java 批量操作

@Autowired @Qualifier("deftenantDataSource")
    private static BasicDataSource abx;

    public static void main(String[] args) {
        abx.getUrl();
        try {
             Class.forName("org.postgresql.Driver");

             Connection conn = DriverManager.getConnection
             ("jdbc:postgresql://localhost/kam","postgres","yinyan");

             PreparedStatement pstmt =
                 conn.prepareStatement("INSERT INTO t_jigyojou_file VALUES (?,?,?)");


             for (int i = 0; i < 10000; i++) {
                 pstmt.setInt(1, i);
                 pstmt.setInt(2,i);
                 pstmt.setString(3,backchar(i));
                 pstmt.addBatch();
            }


             pstmt.executeBatch();
             pstmt.close();

             conn.close();
        } catch (Exception e) {
            // TODO: handle exception
        }

    }

猜你喜欢

转载自blog.csdn.net/fsyczxyy/article/details/88735507
今日推荐