We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
user.xml
<rwSplitUser name="rw1" password="111111" dbGroup="ha_group3" /> <dbGroup rwSplitMode="0" name="ha_group3" delayThreshold="100" > <heartbeat>select user()</heartbeat> <dbInstance name="hostM3" password="111111" url="xxxx:3306" user="test" maxCon="1000" minCon="10" primary="true" /> </dbGroup>
res=9res=10-------end------ sucess-1rw1
mysql端查询的表
mysql> select * from log; +-------+----------------------------------+ | logid | logtitle | +-------+----------------------------------+ | 9 | 802bee57456646baab00807f4df59250 | | 11 | 8ac277707db2fa86017deb27525900a6 | +-------+----------------------------------+
结论: 步长增长不一致
test1.java
package jdbc; import com.google.common.io.Files; import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; public abstract class test1 { static AtomicInteger index = new AtomicInteger(); static AtomicInteger indexs = new AtomicInteger(); static StringBuffer sb = new StringBuffer(); static volatile Connection conn = null; private static List<Connection> list = new ArrayList<>(); private static int update(PreparedStatement psmt, String sql) throws SQLException { psmt = conn.prepareStatement(sql); psmt.setInt(1, 12); psmt.setInt(2, 12); int i = psmt.executeUpdate(); return i; } private static void createConn(String name) { String JDBC_DRIVER = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://127.0.0.1:8066/db1?useSSL=false&allowMultiQueries=true"; // String url = "jdbc:mysql://10.186.62.41:3309?useSSL=false&useServerPrepStmts=true"; String username = name; String password = "123456"; try { // 注册 JDBC 驱动 Class.forName(JDBC_DRIVER); Connection conn = DriverManager.getConnection(url, username, password); list.add(conn); } catch (Exception e) { System.out.println(e.getMessage()); } } private static void test() { String JDBC_DRIVER = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://127.0.0.1:8066?useSSL=false&allowMultiQueries=true"; // String url = "jdbc:mysql://110.186.62.41:3309?useSSL=false&useServerPrepStmts=true"; String username = "root"; String password = "123456"; //String sql = "show @@connection.sql"; String sql = "INSERT INTO log(logid,logtitle)values(null,'802bee57456646baab00807f4df59250'), (null,'8ac277707db2fa86017deb27525900a6');"; ResultSet rs = null; Statement stmt; PreparedStatement ps = null; try { // 注册 JDBC 驱动 Class.forName(JDBC_DRIVER); // if (conn == null) conn = list.get(0); stmt = conn.createStatement(); rs = stmt.executeQuery("use db1;"); ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); ps.executeUpdate(); ResultSet resultSet = ps.getGeneratedKeys(); while(resultSet.next()){ System.out.print("res=" + resultSet.getInt(1) ); } while (resultSet.next()) { System.out.println("dddd " + resultSet.toString()); } System.out.println("-------end------"); System.out.println("sucess" + index.decrementAndGet() + username); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) throws InterruptedException { // int size = 10; // ThreadPoolExecutor executor = new ThreadPoolExecutor(size, size, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>()); int sizes = 5; // createConn("root"); createConn("s3"); test(); } }
The text was updated successfully, but these errors were encountered:
ylinzhu
Successfully merging a pull request may close this issue.
user.xml
res=9res=10-------end------
sucess-1rw1
mysql端查询的表
结论:
步长增长不一致
test1.java
The text was updated successfully, but these errors were encountered: