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.executor.sql.execute.result.query;
19  
20  import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
21  
22  import java.io.InputStream;
23  import java.io.Reader;
24  import java.sql.ResultSet;
25  import java.sql.SQLException;
26  import java.util.Calendar;
27  import java.util.Optional;
28  
29  /**
30   * Query result.
31   */
32  public interface QueryResult extends ExecuteResult, AutoCloseable {
33      
34      /**
35       * Iterate next data.
36       *
37       * @return has next data
38       * @throws SQLException SQL exception
39       */
40      boolean next() throws SQLException;
41      
42      /**
43       * Get data value.
44       *
45       * @param columnIndex column index
46       * @param type class type of data value
47       * @return data value
48       * @throws SQLException SQL exception
49       */
50      Object getValue(int columnIndex, Class<?> type) throws SQLException;
51      
52      /**
53       * Get calendar value.
54       *
55       * @param columnIndex column index
56       * @param type class type of data value
57       * @param calendar calendar
58       * @return calendar value
59       * @throws SQLException SQL exception
60       */
61      Object getCalendarValue(int columnIndex, Class<?> type, @SuppressWarnings("UseOfObsoleteDateTimeApi") Calendar calendar) throws SQLException;
62      
63      /**
64       * Get input stream.
65       *
66       * @param columnIndex column index
67       * @param type class type of data value
68       * @return input stream
69       * @throws SQLException SQL exception
70       */
71      InputStream getInputStream(int columnIndex, String type) throws SQLException;
72      
73      /**
74       * Get CharacterStream.
75       *
76       * @param columnIndex column index
77       * @return reader
78       * @throws SQLException SQL exception
79       */
80      Reader getCharacterStream(int columnIndex) throws SQLException;
81      
82      /**
83       * Judge result set is null or not.
84       *
85       * @return result set is null or not
86       * @throws SQLException SQL exception
87       */
88      boolean wasNull() throws SQLException;
89      
90      /**
91       * Get query result meta data.
92       *
93       * @return query result meta data
94       */
95      QueryResultMetaData getMetaData();
96      
97      /**
98       * Get JDBC result set.
99       *
100      * @return JDBC result set
101      */
102     default Optional<ResultSet> getJDBCResultSet() {
103         return Optional.empty();
104     }
105 }