Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShardingPreparedStatement.execute()方法中缓存语句cachedRoutedPreparedStatements未更新导致的问题 #36

Closed
billberg opened this issue Mar 21, 2016 · 1 comment

Comments

@billberg
Copy link

String sql = "insert into user_info_shard(id,user_no,user_name) values(?,?,?)";
try {
Connection conn = shardingDS.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql);

                for (int i = 1; i <= 10000; i++) {
                    pstmt.setInt(1, i);
                    pstmt.setString(2, UUID.randomUUID().toString().replace("-", ""));
                    pstmt.setString(3,"ZHANG"+i);

                    pstmt.execute();
                }


        } catch(Exception ex) {
            ex.printStackTrace();
        }

单库、分表测试,只有一张逻辑表。
测试代码如上,该测试代码只有第一条记录插入成功,第二条记录插入时就出异常(主键冲突),原因是ShardingPreparedStatement的参数重新设置以后,cachedRoutedPreparedStatements未更新。

@hanahmily
Copy link
Contributor

#106 合并进来

terrymanu pushed a commit that referenced this issue Oct 9, 2018
KomachiSion pushed a commit to KomachiSion/incubator-shardingsphere that referenced this issue Nov 25, 2019
Move package and rename package for apache#33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants