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.database.connector.core.exception;
19  
20  import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
21  import org.apache.shardingsphere.infra.exception.external.sql.sqlstate.XOpenSQLState;
22  
23  /**
24   * Unsupported storage type exception. When this exception is thrown, it means that the relevant jdbcUrl lacks the corresponding {@link DatabaseType} SPI implementation.
25   * Assume that there is a jdbcUrl of `jdbc:vertica://node01.example.com:5433/dbname`, but there is no corresponding implementation of DatabaseType SPI.
26   * User can temporarily create the class and implement {@link DatabaseType#getJdbcUrlPrefixes()} and {@link DatabaseType#getTrunkDatabaseType()}
27   * to require the corresponding jdbcUrl use the SQL92 dialect.
28   * // CHECKSTYLE:OFF
29   * <pre class="code">
30   * public final class VerticaDatabaseType implements DatabaseType {
31   *     &#064;Override
32   *     public Collection<String> getJdbcUrlPrefixes() {
33   *         return Collections.singleton("jdbc:vertica:");
34   *     }
35   *     &#064;Override
36   *     public Optional<DatabaseType> getTrunkDatabaseType() {
37   *         return Optional.of(TypedSPILoader.getService(DatabaseType.class, "SQL92"));
38   *     }
39   *     &#064;Override
40   *     public String getType() {
41   *         return "Vertica";
42   *     }
43   * }
44   * </pre>
45   * // CHECKSTYLE:ON
46   * To fully support the corresponding database dialect, user need to refer to `org.apache.shardingsphere:shardingsphere-infra-database-mysql` module to implement additional SPIs.
47   *
48   * @see org.apache.shardingsphere.database.connector.core.type.DatabaseType
49   */
50  public final class UnsupportedStorageTypeException extends ConnectionURLException {
51      
52      private static final long serialVersionUID = 8981789100727786183L;
53      
54      public UnsupportedStorageTypeException(final String url) {
55          super(XOpenSQLState.FEATURE_NOT_SUPPORTED, 0, "Unsupported storage type of URL '%s'.", url);
56      }
57  }