View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shardingsphere.infra.database.mysql.metadata.database;
19  
20  import org.apache.shardingsphere.infra.database.core.metadata.database.enums.NullsOrderType;
21  import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter;
22  import org.apache.shardingsphere.infra.database.core.metadata.database.metadata.DialectDatabaseMetaData;
23  import org.apache.shardingsphere.infra.database.core.metadata.database.metadata.option.IdentifierPatternType;
24  import org.apache.shardingsphere.infra.database.core.metadata.database.metadata.option.column.DialectColumnOption;
25  import org.apache.shardingsphere.infra.database.core.metadata.database.metadata.option.connection.DialectConnectionOption;
26  import org.apache.shardingsphere.infra.database.core.metadata.database.metadata.option.datatype.DialectDataTypeOption;
27  import org.apache.shardingsphere.infra.database.core.metadata.database.metadata.option.join.DialectJoinOption;
28  import org.apache.shardingsphere.infra.database.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
29  import org.apache.shardingsphere.infra.database.mysql.metadata.database.option.MySQLDataTypeOption;
30  
31  import java.sql.Connection;
32  
33  /**
34   * Database meta data of MySQL.
35   */
36  public final class MySQLDatabaseMetaData implements DialectDatabaseMetaData {
37      
38      @Override
39      public QuoteCharacter getQuoteCharacter() {
40          return QuoteCharacter.BACK_QUOTE;
41      }
42      
43      @Override
44      public IdentifierPatternType getIdentifierPatternType() {
45          return IdentifierPatternType.KEEP_ORIGIN;
46      }
47      
48      @Override
49      public NullsOrderType getDefaultNullsOrderType() {
50          return NullsOrderType.LOW;
51      }
52      
53      @Override
54      public DialectDataTypeOption getDataTypeOption() {
55          return new MySQLDataTypeOption();
56      }
57      
58      @Override
59      public DialectColumnOption getColumnOption() {
60          return new DialectColumnOption(false);
61      }
62      
63      @Override
64      public DialectConnectionOption getConnectionOption() {
65          return new DialectConnectionOption(true, true);
66      }
67      
68      @Override
69      public DialectTransactionOption getTransactionOption() {
70          return new DialectTransactionOption(false, false, true, false, true, Connection.TRANSACTION_REPEATABLE_READ);
71      }
72      
73      @Override
74      public DialectJoinOption getJoinOption() {
75          return new DialectJoinOption(true, true);
76      }
77      
78      @Override
79      public String getDatabaseType() {
80          return "MySQL";
81      }
82  }