Issue Details (XML | Word | Printable)

Key: JDBC-314
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Mark Rotteveel
Reporter: Orlov Sergey
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Jaybird JCA/JDBC Driver

Error when setting connection charset equals "file.encoding" java property

Created: 12/Jul/13 08:53 PM   Updated: 08/Dec/13 09:47 PM
Component/s: JDBC driver
Affects Version/s: Jaybird 2.2.3
Fix Version/s: Jaybird 2.2.4, Jaybird 3.0

Time Tracking:
Not Specified

File Attachments: 1. Text File setCharSet.patch (0.8 kB)



 Description  « Hide
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



 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Orlov Sergey added a comment - 12/Jul/13 09:24 PM
EncodingFactory.getJavaEncodingForAlias(charSet) can return null.
When null are in connection properties org.firebirdsql.gds.impl.wire.ParameterBufferBase$Argument.getValueAsString raise appropriate exception

Mark Rotteveel added a comment - 13/Jul/13 09:11 AM - edited
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.

Mark Rotteveel added a comment - 13/Jul/13 09:12 AM
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