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

CLOBs can cause ClassCastExceptions #3701

Closed
abaus-vc opened this issue Jan 5, 2023 · 0 comments · Fixed by #3708
Closed

CLOBs can cause ClassCastExceptions #3701

abaus-vc opened this issue Jan 5, 2023 · 0 comments · Fixed by #3708

Comments

@abaus-vc
Copy link

abaus-vc commented Jan 5, 2023

I have a file-based database that I sometimes connect to using the sqlline tool for diagnostic purposes. In that DB is a table containing CLOB typed columns:

0: jdbc:h2:/tmp/h2-db> !columns service
+-----------+-------------+------------+----------------------------------+-----------+------------------------+-------------+---------------+----------------+----------------+----------+---------+--+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME |           COLUMN_NAME            | DATA_TYPE |       TYPE_NAME        | COLUMN_SIZE | BUFFER_LENGTH | DECIMAL_DIGITS | NUM_PREC_RADIX | NULLABLE | REMARKS |  |
+-----------+-------------+------------+----------------------------------+-----------+------------------------+-------------+---------------+----------------+----------------+----------+---------+--+
| H2-DB     | PUBLIC      | SERVICE    | ID                               | 12        | CHARACTER VARYING      | 36          | null          | 0              | null           | 0        |         |  |
| H2-DB     | PUBLIC      | SERVICE    | NAME                             | 12        | CHARACTER VARYING      | 63          | null          | 0              | null           | 0        |         |  |
...
| H2-DB     | PUBLIC      | SERVICE    | ADDITIONAL_RESOURCES             | 2005      | CHARACTER LARGE OBJECT | 2147483647  | null          | 0              | null           | 1        |         |  |
| H2-DB     | PUBLIC      | SERVICE    | CONFIG_VALUES                    | 2005      | CHARACTER LARGE OBJECT | 2147483647  | null          | 0              | null           | 1        |         |  |
...
+-----------+-------------+------------+----------------------------------+-----------+------------------------+-------------+---------------+----------------+----------------+----------+---------+--+

When I try to select a result containing these columns, I get a ClassCastException:

0: jdbc:h2:/tmp/h2-db> select * from SERVICE;
java.lang.ClassCastException: class org.h2.value.lob.LobDataFetchOnDemand cannot be cast to class org.h2.value.lob.LobDataDatabase (org.h2.value.lob.LobDataFetchOnDemand and org.h2.value.lob.LobDataDatabase are in unnamed module of loader 'app')
	at org.h2.value.ValueClob.getSQL(ValueClob.java:281)
	at org.h2.util.HasSQL.getSQL(HasSQL.java:62)
	at org.h2.util.HasSQL.getTraceSQL(HasSQL.java:50)
	at org.h2.jdbc.JdbcLob.toString(JdbcLob.java:225)
	at sqlline.Rows$Row.setFormat(Rows.java:313)
	at sqlline.Rows$Row.<init>(Rows.java:282)
	at sqlline.BufferedRows.nextList(BufferedRows.java:118)
	at sqlline.BufferedRows.<init>(BufferedRows.java:54)
	at sqlline.SqlLine.print(SqlLine.java:1770)
	at sqlline.Commands.executeSingleQuery(Commands.java:1139)
	at sqlline.Commands.execute(Commands.java:1079)
	at sqlline.Commands.sql(Commands.java:1033)
	at sqlline.SqlLine.dispatch(SqlLine.java:822)
	at sqlline.SqlLine.begin(SqlLine.java:596)
	at sqlline.SqlLine.start(SqlLine.java:269)
	at sqlline.SqlLine.main(SqlLine.java:208)

H2 JDBC driver version is latest (2.1.214)

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

Successfully merging a pull request may close this issue.

1 participant