Skip to content

Commit

Permalink
be: DbInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Jan 16, 2025
1 parent 1192170 commit 39c6c39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/main/java/com/rebuild/core/support/setup/DbInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ public boolean isMySQL56() {
return desc.contains("5.6.");
}

public boolean isMySQL80() {
public boolean isMySQL8x() {
if (isOceanBase()) return false;
return desc.contains("8.0.") || desc.contains("8.1.");
return desc.startsWith("8.");
}

public boolean isMySQL9x() {
if (isOceanBase()) return false;
return desc.startsWith("9.");
}

public String getDesc() {
return desc;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/rebuild/core/support/setup/Installer.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void install() throws Exception {

if (dbInfo.isOceanBase()) {
installProps.put("db.type", "OceanBase");
} else if (dbInfo.isMySQL80()) {
} else if (dbInfo.isMySQL8x() || dbInfo.isMySQL9x()) {
// https://www.cnblogs.com/lusaisai/p/13372763.html
String dbUrl8 = installProps.getProperty("db.url");
if (!dbUrl8.contains("allowPublicKeyRetrieval")) dbUrl8 += "&allowPublicKeyRetrieval=true";
Expand Down Expand Up @@ -355,7 +355,7 @@ public DbInfo getDbInfo() {

try (Connection conn = getConnection("mysql")) {
try (Statement stmt = conn.createStatement()) {
try (ResultSet rs = stmt.executeQuery("select version()")) {
try (ResultSet rs = stmt.executeQuery("SELECT VERSION()")) {
if (rs.next()) return new DbInfo(rs.getString(1));
}
}
Expand Down

0 comments on commit 39c6c39

Please sign in to comment.