-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow SQL statements to be terminated by semicolon #18472
Comments
Indeed e.g. MySQL accepts any number of trailing semicolons, but rejects any subsequent queries. PostgreSQL even allows multiple queries. Besides SQL injection, I don't know where this is useful Class.forName("org.postgresql.Driver");
try (Connection connection = DriverManager.getConnection("jdbc:postgresql:https://localhost:15432/test", "test", "test");
PreparedStatement stmt = connection.prepareStatement("SELECT 1;;SELECT 2")) {
stmt.execute();
System.out.println("first result set");
stmt.getResultSet().close();
System.out.println("second result set");
System.out.println("getMoreResults = " + stmt.getMoreResults());
stmt.getResultSet().close();
System.out.println("getMoreResults = " + stmt.getMoreResults());
} prints
|
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Several tools generate SQL statements that end with a semicolon. This is supported by most database systems out there. Wikipedia states:
I have not been able to confirm that from the spec, but this has been mentioned in previous conversations in the community.
Note that this is simply a proposal to allow semicolon as a SQL statement terminator and not to support the submission of multiple statements separated by semicolon.
The text was updated successfully, but these errors were encountered: