简体   繁体   English

简单查询:未由SQLite JDBC驱动程序实现

[英]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. 首先使用SQLite + Java破解,当我尝试执行一个简单的简单查询时,我收到了一个错误。

Error: not implemented by SQLite JDBC driver 错误:SQLite JDBC驱动程序未实现

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();

This was a simple cut/paste style error. 这是一个简单的剪切/粘贴样式错误。 When using prepared statements, you shouldn't then pass the SQL into the executeQuery . 使用预准备语句时,不应将SQL传递给executeQuery

Change: 更改:

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

To: 至:

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

This was overriding the preparedStatement . 这超越了preparedStatement

What it was complaining about was executing a query with a '?' 抱怨的是用'?'执行查询 in it since it wasn't the prepared query. 因为它不是准备好的查询。

Check the jdbc driver you have in the libs folder. 检查libs文件夹中的jdbc驱动程序。 It looks like it has not implemented the methods you have called. 看起来它没有实现你调用的方法。

Try downloading the driver from here: https://bitbucket.org/xerial/sqlite-jdbc/downloads 尝试从这里下载驱动程序: https//bitbucket.org/xerial/sqlite-jdbc/downloads

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM