adejanovski / cassandra-jdbc-wrapper

A JDBC wrapper for the Datastax Java Driver for Cassandra
Apache License 2.0
53 stars 36 forks source link

NPE on make columns #6

Closed enekofb closed 8 years ago

enekofb commented 8 years ago

Hi Alexander,

I am trying to put in action liquibase on Cassandra using your JDBC wrapper and I receive following NPE while trying to create an snapshot for a table

Caused by: java.lang.NullPointerException
    at com.github.adejanovski.cassandra.jdbc.MetadataResultSets.makeColumns(MetadataResultSets.java:163)
    at com.github.adejanovski.cassandra.jdbc.CassandraDatabaseMetaData.getColumns(CassandraDatabaseMetaData.java:135)
    at liquibase.snapshot.JdbcDatabaseSnapshot$CachingDatabaseMetaData$3.fastFetchQuery(JdbcDatabaseSnapshot.java:277)
    at liquibase.snapshot.ResultSetCache$SingleResultSetExtractor.fastFetch(ResultSetCache.java:290)
    at liquibase.snapshot.ResultSetCache.get(ResultSetCache.java:58)
    at liquibase.snapshot.JdbcDatabaseSnapshot$CachingDatabaseMetaData.getColumns(JdbcDatabaseSnapshot.java:239)
    at liquibase.snapshot.jvm.ColumnSnapshotGenerator.addTo(ColumnSnapshotGenerator.java:108)

It seems that the statement looses the connection anywhere.

Thanks in advance for your answer,

Eneko.

adejanovski commented 8 years ago

Hi,

it suggests indeed that the connection has been closed sometime before the makeColumns method was called. I'll try to reproduce this on my laptop in order to fix it.

I'll keep you posted.

adejanovski commented 8 years ago

@enekofb : I've reproduced the error in DbVisualizer and fixed it by recreating the statement if it has been closed. Here's the compiled fat jar for you to test : https://drive.google.com/open?id=0B7fwX0DqcWSTbndsQ0JiTXRiT1k

The code is available in the https://github.com/adejanovski/cassandra-jdbc-wrapper/tree/feature/liquibase-error-fix branch.

Let me know how that works out with liquibase. Thanks

adejanovski commented 8 years ago

@enekofb did the fix work ? Let me know if I can close this issue.

enekofb commented 8 years ago

Yes, it solved it.

Thanks!

enekofb commented 8 years ago

Just notice that version 2.1.9 shows the same problem

            <properties>
                <cassandra.version>2.2.6</cassandra.version>
                <cassandra-unit.version>2.2.2.1</cassandra-unit.version>
                <cassandra-driver.version>2.1.9</cassandra-driver.version>
                <cassandra-jdbc-wrapper.version>2.1.9</cassandra-jdbc-wrapper.version>
            </properties>

Caused by: java.lang.NullPointerException: null at com.github.adejanovski.cassandra.jdbc.MetadataResultSets.makeColumns(MetadataResultSets.java:161) ~[cassandra-jdbc-wrapper-2.1.9.jar:na] at com.github.adejanovski.cassandra.jdbc.CassandraDatabaseMetaData.getColumns(CassandraDatabaseMetaData.java:135) ~[cassandra-jdbc-wrapper-2.1.9.jar:na] at liquibase.snapshot.JdbcDatabaseSnapshot$CachingDatabaseMetaData$3.fastFetchQuery(JdbcDatabaseSnapshot.java:277) ~[liquibase-core-3.4.1.jar:na] at liquibase.snapshot.ResultSetCache$SingleResultSetExtractor.fastFetch(ResultSetCache.java:290) ~[liquibase-core-3.4.1.jar:na] at liquibase.snapshot.ResultSetCache.get(ResultSetCache.java:58) ~[liquibase-core-3.4.1.jar:na]

should version 3 of jdbc wrapper be compatible with cassandra v2?