Skip to content
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

Error when setting connection charset equals "file.encoding" java property [JDBC314] #360

Closed
firebird-issue-importer opened this issue Jul 12, 2013 · 7 comments

Comments

@firebird-issue-importer

Submitted by: Orlov Sergey (wasp)

Attachments:
setCharSet.patch

Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at org.firebirdsql.jdbc.FBStatementFactory.createPreparedStatement(FBStatementFactory.java:101)
at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:1187)
at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:942)
at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:896)
at Main.main(Main.java:16)
Caused by: java.lang.RuntimeException: Cannot get the value for this argument type as a string
at org.firebirdsql.gds.impl.wire.ParameterBufferBase$Argument.getValueAsString(ParameterBufferBase.java:185)
at org.firebirdsql.gds.impl.wire.ParameterBufferBase.getArgumentAsString(ParameterBufferBase.java:64)
at org.firebirdsql.gds.impl.GDSHelper.prepareStatement(GDSHelper.java:177)
at org.firebirdsql.jdbc.AbstractStatement.prepareFixedStatement(AbstractStatement.java:1441)
at org.firebirdsql.jdbc.AbstractPreparedStatement.prepareFixedStatement(AbstractPreparedStatement.java:1282)
at org.firebirdsql.jdbc.AbstractPreparedStatement.<init>(AbstractPreparedStatement.java:138)
at org.firebirdsql.jdbc.FBPreparedStatement.<init>(FBPreparedStatement.java:45)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.firebirdsql.jdbc.FBStatementFactory.createPreparedStatement(FBStatementFactory.java:89)
... 4 more

Sample code:

public class Main {
public static void main(String [] args) throws SQLException {
FBSimpleDataSource ds = new FBSimpleDataSource();
ds.setDatabase("localhost:w:/progs/firebird/2.5.2.26539/examples/empbuild/EMPLOYEE.FDB");
ds.setUserName("SYSDBA");
ds.setPassword("masterkey");
ds.setCharSet("cp1251");
Connection con = ds.getConnection();
PreparedStatement sql = con.prepareStatement("select EMP_NO From Employee", 0, ResultSet.TYPE_SCROLL_INSENSITIVE);
}
java -Dfile.encoding=cp1251 -cp jaybird-full-2.2.3.jar;. Main

Commits: a3c3ef1 FirebirdSQL/fbt-repository@22d2722 FirebirdSQL/fbt-repository@a691022

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 13, 2013

Commented by: Orlov Sergey (wasp)

EncodingFactory.getJavaEncodingForAlias(charSet) can return null.
When null are in connection properties org.firebirdsql.gds.impl.wire.ParameterBufferBase$Argument.getValueAsString raise appropriate exception

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 13, 2013

Modified by: Orlov Sergey (wasp)

Attachment: setCharSet.patch [ 12344 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 13, 2013

Commented by: @mrotteveel

Thanks for the report. I will use a slightly different solution than your patch, as we actually need the original (or any) charSet name for the second part of the setter.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 13, 2013

Commented by: @mrotteveel

Scheduled for 2.2.4 and 2.3. Solution for 2.3 will initially be committed to the wire protocol improvements branch as I am currently overhauling the character set / encoding implementation for Jaybird 2.3

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 13, 2013

Modified by: @mrotteveel

Fix Version: Jaybird 2.2.4 [ 10531 ]

Fix Version: Jaybird 2.3 [ 10440 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 13, 2013

Modified by: @mrotteveel

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 8, 2013

Modified by: @mrotteveel

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants