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

JDBC setBoolean implementation #274

Closed
pedorich-n opened this issue Oct 21, 2018 · 2 comments
Closed

JDBC setBoolean implementation #274

pedorich-n opened this issue Oct 21, 2018 · 2 comments

Comments

@pedorich-n
Copy link

pedorich-n commented Oct 21, 2018

Hi there!
Why does the implementation of setBoolean in JDBC drive converts values to t or f? I get an exception java.sql.SQLException: Query failed : Exception: Cannot compare between BOOLEAN and VARCHAR.

I'm using mapdjdbc-1.0-SNAPSHOT-jar-with-dependencies.jar and as I see, implementation is the same in master branch, https://github.com/omnisci/mapd-core/blob/master/java/mapdjdbc/src/main/java/com/mapd/jdbc/MapDPreparedStatement.java#L167

Example code:

  val sql  = s"select 1 from example where hasException = ?"
  val stmt = ConnectionPool.get().borrow().prepareStatement(sql)
  stmt.setBoolean(1, false)
  val resultSet = stmt.executeQuery()
  println(resultSet.getInt(1))
22:22:24.092 [run-main-6] DEBUG com.mapd.jdbc.MapDStatement - sql is :'select 1 from example where hasException = 'f' LIMIT 100000'
22:22:24.092 [run-main-6] DEBUG com.mapd.jdbc.MapDStatement - afterFnSQL is :'select 1 from example where hasException = 'f' LIMIT 100000'

I obtain connection via ScalikeJDBC's ConnectionPool, but it's the same as DriverManager.getConnection(...)

  Class.forName("com.mapd.jdbc.MapDDriver")
  ConnectionPool.singleton("jdbc:mapd:192.168.1.9:9091:db_test", "mapd", "HyperInteractive")

Am I doing something wrong?

@pedorich-n
Copy link
Author

Another question: can I build JDBC driver only? Without building whole core?

andrewseidl added a commit that referenced this issue Oct 24, 2018
Previously the generated sql was of the form:

    WHERE column = "f"

Now it generates:

    WHERE column = false

Resolves #274
@andrewseidl
Copy link
Contributor

Thanks for the report. I've pushed a potential fix here: #276 , should be merged in a day or so.

I've opened #277 requesting adding how to build the JDBC driver on its own. It's possible, but it's currently intertwined with the rest of our CMake-based build. It's basically two thrift -gen java runs to generate the bindings, then need to remember to set a few properties when running maven.

andrewseidl added a commit that referenced this issue Oct 29, 2018
Previously the generated sql was of the form:

    WHERE column = "f"

Now it generates:

    WHERE column = false

Resolves #274
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