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

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.0

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(
        at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(
        at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(
        at org.firebirdsql.jdbc.AbstractConnection.prepareStatement(
        at Main.main(
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(
        at org.firebirdsql.gds.impl.wire.ParameterBufferBase.getArgumentAsString(
        at org.firebirdsql.gds.impl.GDSHelper.prepareStatement(
        at org.firebirdsql.jdbc.AbstractStatement.prepareFixedStatement(
        at org.firebirdsql.jdbc.AbstractPreparedStatement.prepareFixedStatement(
        at org.firebirdsql.jdbc.AbstractPreparedStatement.<init>(
        at org.firebirdsql.jdbc.FBPreparedStatement.<init>(
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
        at java.lang.reflect.Constructor.newInstance(
        at org.firebirdsql.jdbc.FBStatementFactory.createPreparedStatement(
        ... 4 more

Sample code:

public class Main {
    public static void main(String [] args) throws SQLException {
        FBSimpleDataSource ds = new FBSimpleDataSource();
        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   Change History   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