
If you were logged in you would be able to see more operations.
|
|
|
When I try to create an object using escape syntax, provided the keyword is in uppercase, I get the exception
org.firebirdsql.jdbc.escape.FBSQLParseException: Unexpected first character inside JDBC escape: C
Code
try (Connection con = DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:c:/db/employee.fdb", "SYSDBA", "masterkey")) {
CallableStatement stmt = con.prepareCall("{CALL sp_test(?)}");
stmt.close();
}
Call stack
Exception in thread "main" org.firebirdsql.jdbc.escape.FBSQLParseException: Unexpected first character inside JDBC escape: C
at org.firebirdsql.jdbc.escape.FBEscapedParser$ParserState$4.nextState(FBEscapedParser.java:461)
at org.firebirdsql.jdbc.escape.FBEscapedParser.parse(FBEscapedParser.java:114)
at org.firebirdsql.jdbc.FBConnection.nativeSQL(FBConnection.java:330)
at org.firebirdsql.jdbc.FBStatement.nativeSQL(FBStatement.java:904)
at org.firebirdsql.jdbc.AbstractCallableStatement.<init>(AbstractCallableStatement.java:80)
at org.firebirdsql.jdbc.FBCallableStatement.<init>(FBCallableStatement.java:43)
at org.firebirdsql.jdbc.FBConnection.prepareCall(FBConnection.java:811)
at org.firebirdsql.jdbc.FBConnection.prepareCall(FBConnection.java:777)
at org.firebirdsql.jdbc.FBConnection.prepareCall(FBConnection.java:297)
at test.DBTest.main(DBTest.java:10)
The problem is in method nextState of class ESCAPE_ENTER_STATE
ESCAPE_ENTER_STATE {
protected FBEscapedParser.ParserState nextState(char inputChar) throws FBSQLParseException {
switch(inputChar) {
case '?':
case 'c':
case 'd':
case 'e':
case 'f':
case 'l':
case 'o':
case 't':
return NORMAL_STATE;
default:
throw new FBSQLParseException("Unexpected first character inside JDBC escape: " + inputChar);
}
}
}
This method assumes that the first letter of the keyword should be written in lowercase. Although later, when converting the escape command to native code, there is a forced conversion to lowercase
public final class FBEscapedParser {
...............
private void escapeToNative(StringBuilder target, String escaped) throws SQLException {
StringBuilder keyword = new StringBuilder();
StringBuilder payload = new StringBuilder(Math.max(16, escaped.length()));
this.processEscaped(escaped, keyword, payload);
String keywordStr = keyword.toString().toLowerCase();
as a consequence, this code works
CallableStatement stmt = con.prepareCall("{сALL sp_test(?)}");
(first letter in lower case)
|
Description
|
When I try to create an object using escape syntax, provided the keyword is in uppercase, I get the exception
org.firebirdsql.jdbc.escape.FBSQLParseException: Unexpected first character inside JDBC escape: C
Code
try (Connection con = DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:c:/db/employee.fdb", "SYSDBA", "masterkey")) {
CallableStatement stmt = con.prepareCall("{CALL sp_test(?)}");
stmt.close();
}
Call stack
Exception in thread "main" org.firebirdsql.jdbc.escape.FBSQLParseException: Unexpected first character inside JDBC escape: C
at org.firebirdsql.jdbc.escape.FBEscapedParser$ParserState$4.nextState(FBEscapedParser.java:461)
at org.firebirdsql.jdbc.escape.FBEscapedParser.parse(FBEscapedParser.java:114)
at org.firebirdsql.jdbc.FBConnection.nativeSQL(FBConnection.java:330)
at org.firebirdsql.jdbc.FBStatement.nativeSQL(FBStatement.java:904)
at org.firebirdsql.jdbc.AbstractCallableStatement.<init>(AbstractCallableStatement.java:80)
at org.firebirdsql.jdbc.FBCallableStatement.<init>(FBCallableStatement.java:43)
at org.firebirdsql.jdbc.FBConnection.prepareCall(FBConnection.java:811)
at org.firebirdsql.jdbc.FBConnection.prepareCall(FBConnection.java:777)
at org.firebirdsql.jdbc.FBConnection.prepareCall(FBConnection.java:297)
at test.DBTest.main(DBTest.java:10)
The problem is in method nextState of class ESCAPE_ENTER_STATE
ESCAPE_ENTER_STATE {
protected FBEscapedParser.ParserState nextState(char inputChar) throws FBSQLParseException {
switch(inputChar) {
case '?':
case 'c':
case 'd':
case 'e':
case 'f':
case 'l':
case 'o':
case 't':
return NORMAL_STATE;
default:
throw new FBSQLParseException("Unexpected first character inside JDBC escape: " + inputChar);
}
}
}
This method assumes that the first letter of the keyword should be written in lowercase. Although later, when converting the escape command to native code, there is a forced conversion to lowercase
public final class FBEscapedParser {
...............
private void escapeToNative(StringBuilder target, String escaped) throws SQLException {
StringBuilder keyword = new StringBuilder();
StringBuilder payload = new StringBuilder(Math.max(16, escaped.length()));
this.processEscaped(escaped, keyword, payload);
String keywordStr = keyword.toString().toLowerCase();
as a consequence, this code works
CallableStatement stmt = con.prepareCall("{сALL sp_test(?)}");
(first letter in lower case)
|
Show » |
|
This a regression compared to Jaybird 2.2.x introduced in 3.0.0; I will fix this in Jaybird 4.0.2 and 3.0.10 (and Jaybird 5). Unfortunately, you reported this just while I was releasing 4.0.1, I have no set date for releasing 4.0.2.
As a workaround, I recommend using the syntax as specified by JDBC (that is: lowercase `call`).