File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
APIJSON-Java-Server/APIJSONDemo/src/main/java/apijson/demo/server Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -45,15 +45,15 @@ public class DemoSQLConfig extends AbstractSQLConfig {
4545 @ Override
4646 public String getDBUri () {
4747 //TODO 改成你自己的
48- return DATABASE_POSTGRESQL .equals (getDatabase ()) ? "jdbc:postgresql://localhost:5432" : "jdbc:mysql://localhost:3306" ;
48+ return DATABASE_POSTGRESQL .equalsIgnoreCase (getDatabase ()) ? "jdbc:postgresql://localhost:5432" : "jdbc:mysql://localhost:3306" ;
4949 }
5050 @ Override
5151 public String getDBAccount () {
52- return DATABASE_POSTGRESQL .equals (getDatabase ()) ? "postgres" : "root" ; //TODO 改成你自己的
52+ return DATABASE_POSTGRESQL .equalsIgnoreCase (getDatabase ()) ? "postgres" : "root" ; //TODO 改成你自己的
5353 }
5454 @ Override
5555 public String getDBPassword () {
56- return DATABASE_POSTGRESQL .equals (getDatabase ()) ? null : "apijson" ; //TODO 改成你自己的
56+ return DATABASE_POSTGRESQL .equalsIgnoreCase (getDatabase ()) ? null : "apijson" ; //TODO 改成你自己的
5757 }
5858 @ Override
5959 public String getSchema () {
@@ -63,8 +63,8 @@ public String getSchema() {
6363
6464 @ JSONField (serialize = false )
6565 @ Override
66- public String getTablePath () {
67- return DATABASE_POSTGRESQL .equals (getDatabase ()) ? getSQLTable () : super .getTablePath ();
66+ public String getTablePath () { //PostgreSQL 不允许 cross-database
67+ return DATABASE_POSTGRESQL .equalsIgnoreCase (getDatabase ()) ? getSQLTable () : super .getTablePath ();
6868 }
6969
7070
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ private PreparedStatement getStatement(@NotNull SQLConfig config) throws Excepti
7777 Log .i (TAG , "select connection " + (connection == null ? " = null" : ("isClosed = " + connection .isClosed ()))) ;
7878
7979
80- if (DemoSQLConfig .DATABASE_POSTGRESQL .equals (config .getDatabase ())) {
80+ if (DemoSQLConfig .DATABASE_POSTGRESQL .equalsIgnoreCase (config .getDatabase ())) { //PostgreSQL 不允许 cross-database
8181 connection = DriverManager .getConnection (config .getDBUri () + "/" + config .getSchema (), config .getDBAccount (), config .getDBPassword ());
8282 }
8383 else {
@@ -93,7 +93,7 @@ private PreparedStatement getStatement(@NotNull SQLConfig config) throws Excepti
9393
9494 for (int i = 0 ; i < valueList .size (); i ++) {
9595
96- if (DemoSQLConfig .DATABASE_POSTGRESQL .equals (config .getDatabase ())) {
96+ if (DemoSQLConfig .DATABASE_POSTGRESQL .equalsIgnoreCase (config .getDatabase ())) {
9797 statement .setObject (i + 1 , valueList .get (i )); //PostgreSQL JDBC 不支持隐式类型转换 tinyint = varchar 报错
9898 }
9999 else {
You can’t perform that action at this time.
0 commit comments