Menu ▾ ▴

#1464 ClassCastException

SQuirreL
open
nobody
None
medium
2022-09-18
2021-03-10
Ulf Dittmer
No

I'm getting a ClassCastException when executing the query "select zbytes from zblob" against the attached SQLite DB using sqlite-jdbc-3.34.0.jar as driver. The field that causes the issue is shown as type "BLOB" in the "Columns" tab. This does not happen when looking at the table in the "Content" tab (where the popup window shows the data just fine when I double-click the value).

java.lang.ClassCastException: java.lang.String cannot be cast to net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BlobDescriptor
at net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeBlob.isEditableInPopup(DataTypeBlob.java:370)
at net.sourceforge.squirrel_sql.fw.datasetviewer.coloring.ColoringService.colorCell(ColoringService.java:48)
at net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.CellRenderer.getTableCellRendererComponent(CellRenderer.java:43)

1 Attachments

Discussion

  • Gerd Wagner

    Gerd Wagner - 2021-03-13

    This is a database or JDBC driver problem. You should contact your database or JDBC driver vendor. Here are the details:

    For the SQL "SELECT ZBYTES FROM ZBLOB" the driver returns
    ResultSet.getMetaData().getColumnName(1) = ZBYTES
    ResultSet.getMetaData().getColumnTypeName(1) = BLOB
    ResultSet.getMetaData().getColumnType(1) = 2004
    Although calling ResultSet.getBlob() results in an error. This error then causes the error you observed.

    Another inconsistency is that
    Connection().getMetaData().getColumns(null, null, "ZBLOB", "ZBYTES").getString("DATA_TYPE") return 12 which is Varchar, see https://docs.oracle.com/javase/8/docs/api/java/sql/Types.html
    This is why the column ZBYTES value is shown in the Object trees contents tab.

    Nonetheless SQuirreL's error handling at this point was poor. I fixed that and with the next snapshot you'll get better error messages which even point to a work around for your problem.

     
  • Ulf Dittmer

    Ulf Dittmer - 2022-08-30

    The sqlite-jdbc folks think it's OK that calling getBlob throws an exception, since it's not a required method, and suggest falling back to getBytes instead. See https://github.com/xerial/sqlite-jdbc/issues/589 for the discussion,

     
  • Gerd Wagner

    Gerd Wagner - 2022-09-07

    Could you please give snapshot-20220907_2225 a try.

     
  • Ulf Dittmer

    Ulf Dittmer - 2022-09-18

    That works. Thank you very much!

     

Log in to post a comment.