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

Problem reading CLOB values from Oracle #12

Closed
mbknor opened this issue May 3, 2013 · 0 comments
Closed

Problem reading CLOB values from Oracle #12

mbknor opened this issue May 3, 2013 · 0 comments

Comments

@mbknor
Copy link
Contributor

mbknor commented May 3, 2013

I try to map an Oracle CLOB column to a String.
Sql2o called toString on the Clob-object and gets a string ala "com.oracle.Clob@6756767".

I worked around the problem like this:

    private static class ClobConverter extends StringConverter {
        @Override
        public String convert(Object o) {
            if ( o instanceof Clob) {
                Clob clob = (Clob)o;
                try {
                    return clob.getSubString(1, (int)clob.length());
                } catch (SQLException e) {
                    throw new RuntimeException("Error reading clob-value", e);
                }
            } else {
                return super.convert(o);
            }
        }
    }

and

Convert.registerConverter(String.class, new ClobConverter());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants