Skip to content

Implement some JDBC methods to support DataGrip#3181

Merged
qiaojialin merged 3 commits intomasterfrom
jdbc_maxrows
May 14, 2021
Merged

Implement some JDBC methods to support DataGrip#3181
qiaojialin merged 3 commits intomasterfrom
jdbc_maxrows

Conversation

@liutaohua
Copy link
Copy Markdown
Contributor

The getMaxRow and getMoreResults methods are used to connect IoTDB using DataGrip.

IoTDB-JDBC is not currently supported.

I implemented two methods in which getMoreResults are always returning false instead of throwing an exception.

It looks OK in my local tests so far.

image

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

19.2% 19.2% Coverage
0.0% 0.0% Duplication

@Override
public boolean getMoreResults() throws SQLException {
throw new SQLException("Not support getMoreResults");
return false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds incorrect...
getMoreResults should return false either:

  1. the number of fetched rows >= maxRows
  2. no more results from resultSet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a statement executes multiple SELECTs, the result returned becomes a result with multiple results.
getMoreResults are used to obtain the next result set in this case.

ResultSet resultSet = preparedStatement.executeQuery("select * from root.group_9.d_9 slimit 10;select * from root.group_8.d_8 slimit 10;");

I tested whether the server supports multiple SELECT execution at the same time, and I got this error:

org.apache.iotdb.jdbc.IoTDBSQLException: 401: Error occurred while parsing SQL to physical plan: line 1:41 mismatched input 'select' expecting <EOF>

Obviously the server doesn't support it, so here I think it's correct to always return false.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from JDBC javaDoc. I agree with @liutaohua .

boolean getMoreResults()
                throws SQLException
Moves to this Statement object's next result, returns true if it is a ResultSet object, and implicitly closes any current ResultSet object(s) obtained with the method getResultSet.
There are no more results when the following is true:


     // stmt is a Statement object
     ((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1))
 
Returns:
true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws:
SQLException - if a database access error occurs or this method is called on a closed Statement

@qiaojialin qiaojialin merged commit 0b964a1 into master May 14, 2021
@qiaojialin qiaojialin deleted the jdbc_maxrows branch May 14, 2021 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants