› MySQL 5.5 Community Server
› MySQL 5.6 Community Server
› Percona Configuration Wizard
› XtraBackup 搭建主从复制
Great Sites on MySQL
› Percona
› MySQL Performance Blog
› Severalnines
推荐管理工具
› Sequel Pro
› phpMyAdmin
推荐书目
› MySQL Cookbook
MySQL 相关项目
› MariaDB
› Drizzle
参考文档
› http://mysql-python.sourceforge.net/MySQLdb.html
bubuXiaoqi
V2EX  ›  MySQL

MYSQL 批处理的时候不能返回自增值?

  •  
  •   bubuXiaoqi · Jul 11, 2019 · 5321 views
    This topic created in 2632 days ago, the information mentioned may be changed or developed.

    代码: stmt = conn.createStatement(); for (String sql : sqlStr) { stmt.addBatch(sql); } stmt.executeBatch(); rs = stmt.getGeneratedKeys();

    异常: java.sql.SQLException: Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate(), Statement.executeLargeUpdate() or Connection.prepareStatement().

    1 replies  •  2019-07-11 11:39:45 +08:00
    bubuXiaoqi
        1
    bubuXiaoqi  
    OP
       Jul 11, 2019
    网上查资料 说是 只有
    Statement.executeUpdate(),
    Statement.executeLargeUpdate()
    Connection.prepareStatement().

    这三个地方可以加 Statement.RETURN_GENERATED_KEYS。
    可是我不方便用预处理,但是也需要用批处理。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   846 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 20:47 · PVG 04:47 · LAX 13:47 · JFK 16:47
    ♥ Do have faith in what you're doing.