You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/08/04 23:09:20 UTC

[GitHub] [shardingsphere] mabaiwan commented on a diff in pull request #19841: Redesign JDBCRepository and H2Repository

mabaiwan commented on code in PR #19841:
URL: https://github.com/apache/shardingsphere/pull/19841#discussion_r938320263


##########
shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProvider.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mode.repository.standalone.jdbc;
+
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
+
+/**
+ * JDBC repository provider.
+ */
+@SingletonSPI
+public interface JDBCRepositoryProvider extends TypedSPI {
+    
+    /**
+     * Drop table SQL.
+     *
+     * @return SQL to drop table
+     */
+    default String dropTableSQL() {
+        return "DROP TABLE IF EXISTS repository";
+    }
+    
+    /**
+     * Create table SQL.
+     *
+     * @return SQL to create table
+     */
+    default String createTableSQL() {
+        return "CREATE TABLE repository(id varchar(36) PRIMARY KEY, `key` TEXT, `value` TEXT, parent TEXT)";
+    }
+    
+    /**
+     * Select by key SQL.
+     *
+     * @return SQL to select table
+     */
+    default String selectByKeySQL() {
+        return "SELECT `value` FROM repository WHERE `key` = ?";
+    }
+    
+    /**
+     * Select by parent key SQL.
+     *
+     * @return SQL to select table
+     */
+    default String selectByParentKeySQL() {
+        return "SELECT `key` FROM repository WHERE parent = ?";
+    }
+    
+    /**
+     * Insert SQL.
+     *
+     * @return SQL to insert table
+     */
+    default String insertSQL() {
+        return "INSERT INTO repository VALUES(?, ?, ?, ?)";
+    }
+    
+    /**
+     * Update SQL.
+     *
+     * @return SQL to update table
+     */
+    default String updateSQL() {
+        return "UPDATE repository SET `value` = ? WHERE `key` = ?";
+    }
+    
+    /**
+     * Delete SQL.
+     *
+     * @return SQL to delete table
+     */
+    default String deleteSQL() {
+        return "UPDATE repository SET `value` = ? WHERE `key` = ?";
+    }
+    
+    /**
+     * Get default JDBC url.
+     *
+     * @return Default JDBC url
+     */
+    default String getDefaultJDBCUrl() {
+        return "";
+    }
+    
+    /**
+     * Get default user.
+     *
+     * @return Default user
+     */
+    default String getDefaultUser() {

Review Comment:
   For example, the H2 database can use the default username and password, because the user does not pay attention to these



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org