Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple query: not implemented by SQLite JDBC driver

First crack at using SQLite+Java and I'm recieving an error when I attempt to execute a simple simple query.

Error: not implemented by SQLite JDBC driver

Query:

String sql = 
    "select Asset, Qty*Price+Fees as Cost \n" +
    "from   Transactions t \n" +
    "       inner join TransactionItems i on t.Id = i.TransactionId \n" +
    "where  TransDate <= ? \n";

try (PreparedStatement stmt = cnn.prepareStatement(sql)) {
    java.sql.Date dte = new java.sql.Date(SumDate().getTimeInMillis());
    stmt.setDate(1, dte);

    try(ResultSet rs = stmt.executeQuery(sql)) {
        while(rs.next()) {
            PortfolioSummaryItem item = new PortfolioSummaryItem(PortfolioSummary.this);
            item.Load(rs);
            items.put(item.asset,item);
        }
        rs.close();
    }

    stmt.close();
like image 526
Jefferey Cave Avatar asked Dec 21 '13 21:12

Jefferey Cave


1 Answers

This was a simple cut/paste style error. When using prepared statements, you shouldn't then pass the SQL into the executeQuery.

Change:

try(ResultSet rs = stmt.executeQuery(sql)){

To:

try(ResultSet rs = stmt.executeQuery()){

This was overriding the preparedStatement.

What it was complaining about was executing a query with a '?' in it since it wasn't the prepared query.

like image 194
Jefferey Cave Avatar answered Oct 10 '22 22:10

Jefferey Cave