From 036141d4d787516735eec1eb076f74ab84ea9ffa Mon Sep 17 00:00:00 2001 From: Icemap Date: Tue, 31 May 2022 16:34:23 +0800 Subject: [PATCH 1/5] [Update] mysql-client to mycli --- Expected-Output.md | 51 +++++++++++++++++-------------- README.md | 2 +- plain-java-batch-update/Makefile | 2 +- plain-java-batch-update/README.md | 2 +- plain-java-jdbc/Makefile | 9 +++--- plain-java-mybatis/Makefile | 4 +-- 6 files changed, 38 insertions(+), 32 deletions(-) diff --git a/Expected-Output.md b/Expected-Output.md index dbccd8f..8ca6422 100644 --- a/Expected-Output.md +++ b/Expected-Output.md @@ -5,8 +5,9 @@ ``` cheese@CheesedeMacBook-Pro tidb-example-java % make plain-java-jdbc /Library/Developer/CommandLineTools/usr/bin/make -C plain-java-jdbc -make mysql build run -mysql --host 127.0.0.1 --port 4000 -u root goods: 1 PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('a3e0204c-6ae8-40b9-b5f0-82b27c322733', 7130, 3033)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('6d2e7fee-619c-4d5b-a583-ae883e8d3ec0', 7630, 8354)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('b85731d2-9f8d-4caa-a3af-4e794fe77513', 7154, 8454)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('f0ce6a8c-acd4-4d79-b7f5-2855eea539a7', 5065, 7030)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('6b9e9704-7443-4188-8461-461886686707', 2495, 4159)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('68674ff8-9b0c-4ea9-8f5b-09a41c59417c', 7197, 3929)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('921b2b67-a3c3-40a0-a864-048ac0275e49', 3165, 3196)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('3d2d7b48-5f56-4055-b9be-ea94975eb498', 6515, 3065)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('08b89a63-04d7-4a28-a0ed-2bc2290a05b3', 6360, 8511)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('c2a71629-f4aa-44d1-b1e7-82b354ced9da', 8993, 1540)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('c8a9ecfd-4951-40c9-b6b2-bf2b25aa12a6', 286, 7687)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('f63401ec-aad6-4a75-bb5d-01e492239578', 2654, 7343)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('4d9d361f-c4ba-496b-bd07-32310bce280b', 1936, 5775)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('8e1eb450-7141-4181-9170-c05b36b3708e', 6582, 1717)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('7a42bf2f-4a59-4095-aa2a-b29399ad3b69', 6104, 433)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('fb9636cd-79bb-4aad-91b8-6e9ce0af32a0', 3579, 5805)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('301b45c3-358f-4fa5-a7f0-168d00541824', 6644, 9277)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('8f812d3d-9241-431a-abfe-5b187ac6d748', 3540, 8821)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('c075f09d-3014-45fc-947f-debe1760f2ed', 7729, 929)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('c7038d22-1bda-488e-9f7f-9f35e7f557c9', 437, 7100)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('df1ff19b-4a05-41b2-a1c5-b80aad1272e4', 8372, 3109)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('d468b4da-882a-4ef7-b4f0-b91282de89aa', 1003, 5628)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('b41b979f-40a6-4226-ae02-1130d4d00bb2', 6593, 2853)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('188d8934-6175-437d-b20d-f28b019eefcb', 7858, 3428)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('969e8ad4-b4f7-47c8-bc28-ff4b08f0b8e0', 5695, 8058)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('4a102df6-65e1-48d4-9b5b-385e9f7516f1', 4582, 5716)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('ad4d54e2-83e4-4367-a275-81591219dd0b', 7843, 5973)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('c3eafc1e-ce2d-4e38-91a6-b85f79a4882b', 5059, 9729)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('4b9b5bcc-8ecc-4d89-b2cb-285055e8492c', 2249, 185)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('eb3e2d7d-fa70-482a-9f0d-ede2bdf379ac', 6138, 5993)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('6c4154d2-6701-4a5f-928b-7353408c6195', 5555, 5684)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('9de37d0a-c4e0-46a0-8f0f-791e712a89fa', 8369, 1506)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: - 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('45f9c266-8047-4d9e-a86e-5780668be105', 5816, 8106)' + 'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO player (id, coins, goods) VALUES ('6c0b2a6e-4cba-46e4-aac7-c57bfdbd7185', 2709, 7211)' => 114 row(s) updated in this batch PlayerDAO.bulkInsertRandomPlayers: => 1938 total inserted players @@ -153,11 +154,13 @@ PlayerDAO.buyGoods: coins => 100 goods => 0 + [buyGoods]: 'check goods and coins enough' id => 2 coins => 114514 goods => 20 + [buyGoods] ERROR: { state => null, cause => null, message => buy player 1 coins not enough. } [buyGoods] Rollback PlayerDAO.buyGoods: @@ -172,12 +175,14 @@ PlayerDAO.buyGoods: coins => 100 goods => 0 + [buyGoods]: 'check goods and coins enough' id => 2 coins => 114514 goods => 20 + [buyGoods]: 'trade success' PlayerDAO.buyGoods: diff --git a/README.md b/README.md index 2afe605..71bda64 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The process is as follows: - [Java 17](https://www.oracle.com/java/technologies/downloads/) ([OpenJDK](https://openjdk.java.net/) also supports) - [Maven](https://maven.apache.org/) -- mysql client +- mycli ## plain-java-jdbc diff --git a/plain-java-batch-update/Makefile b/plain-java-batch-update/Makefile index c02be43..53b9b75 100644 --- a/plain-java-batch-update/Makefile +++ b/plain-java-batch-update/Makefile @@ -19,7 +19,7 @@ all: prepare: tiup demo bookshop prepare --drop-tables - mysql --host 127.0.0.1 --port 4000 -u root Date: Tue, 31 May 2022 16:51:31 +0800 Subject: [PATCH 2/5] [Update] mysql-client to mycli --- .gitpod.Dockerfile | 6 ++++-- .gitpod.yml | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 77b9386..34afe8e 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -1,5 +1,7 @@ FROM gitpod/workspace-java-17 -RUN sudo apt install mysql-client -y -RUN curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh +RUN sudo apt-get install python3-pip -y && \ + sudo pip install pip -U -q && \ + sudo pip install mycli -q && \ + curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh diff --git a/.gitpod.yml b/.gitpod.yml index eca0263..3e55cb6 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -22,15 +22,13 @@ tasks: cd plain-java-jdbc code src/main/resources/dbinit.sql code src/main/java/com/pingcap/JDBCExample.java - make mysql + make all elif [ "$targetMode" == "plain-java-hibernate" ] then - cd plain-java-hibernate - make + make plain-java-hibernate elif [ "$targetMode" == "spring-jpa-hibernate" ] then - cd spring-jpa-hibernate - make + make spring-jpa-hibernate fi ports: From abad495a135e1016567138176ec31eb36befc105 Mon Sep 17 00:00:00 2001 From: Cheese Date: Tue, 31 May 2022 17:20:40 +0800 Subject: [PATCH 3/5] Update plain-java-mybatis/Makefile Co-authored-by: Mini256 --- plain-java-mybatis/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plain-java-mybatis/Makefile b/plain-java-mybatis/Makefile index b11d1a4..4a59cf5 100644 --- a/plain-java-mybatis/Makefile +++ b/plain-java-mybatis/Makefile @@ -17,7 +17,7 @@ all: make mysql gen build run -mysql: +prepare: mycli --host 127.0.0.1 --port 4000 -u root --no-warn < src/main/resources/dbinit.sql mycli --host 127.0.0.1 --port 4000 -u root -e "TRUNCATE test.player" From 7cdc662ce28cb175592c1b6a2ef78ae9a6033d77 Mon Sep 17 00:00:00 2001 From: Icemap Date: Tue, 31 May 2022 17:21:48 +0800 Subject: [PATCH 4/5] [Update] make command name --- plain-java-mybatis/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plain-java-mybatis/Makefile b/plain-java-mybatis/Makefile index 4a59cf5..98707f0 100644 --- a/plain-java-mybatis/Makefile +++ b/plain-java-mybatis/Makefile @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -.PHONY: all gen build run +.PHONY: all prepare gen build run all: - make mysql gen build run + make prepare gen build run prepare: mycli --host 127.0.0.1 --port 4000 -u root --no-warn < src/main/resources/dbinit.sql From c8101baf04e4c724108b07318f97b1a8201d8dec Mon Sep 17 00:00:00 2001 From: Icemap Date: Tue, 31 May 2022 17:40:52 +0800 Subject: [PATCH 5/5] [Debug] TRUNCATE location --- Expected-Output.md | 2 +- plain-java-jdbc/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Expected-Output.md b/Expected-Output.md index 8ca6422..acfaa1b 100644 --- a/Expected-Output.md +++ b/Expected-Output.md @@ -6,8 +6,8 @@ cheese@CheesedeMacBook-Pro tidb-example-java % make plain-java-jdbc /Library/Developer/CommandLineTools/usr/bin/make -C plain-java-jdbc make prepare build run -mycli --host 127.0.0.1 --port 4000 -u root -e "TRUNCATE test.player" mycli --host 127.0.0.1 --port 4000 -u root --no-warn < src/main/resources/dbinit.sql +mycli --host 127.0.0.1 --port 4000 -u root -e "TRUNCATE test.player" mvn clean package [INFO] Scanning for projects... [INFO] diff --git a/plain-java-jdbc/Makefile b/plain-java-jdbc/Makefile index 9fdfc87..dff84c9 100644 --- a/plain-java-jdbc/Makefile +++ b/plain-java-jdbc/Makefile @@ -18,8 +18,8 @@ all: make prepare build run prepare: - mycli --host 127.0.0.1 --port 4000 -u root -e "TRUNCATE test.player" mycli --host 127.0.0.1 --port 4000 -u root --no-warn < src/main/resources/dbinit.sql + mycli --host 127.0.0.1 --port 4000 -u root -e "TRUNCATE test.player" build: mvn clean package