如何在Java中的Sqlite中更新ResultSet [英] How to update ResultSet in Sqlite in Java

查看:371
本文介绍了如何在Java中的Sqlite中更新ResultSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Java中的SQLite更新我的ResultSet.当我尝试更新结果集时,它给了我一个例外:java.sql.SQLException: not implemented by SQLite JDBC driver.我也做过:

I want to update my ResultSet with using SQLite in Java. When i am trying to update the Resultset it is giving me an exception : java.sql.SQLException: not implemented by SQLite JDBC driver. i have also done :

stmt = c.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

但仍然出现异常,我认为这是因为我们无法使用SQLite DB更新结果集.请帮助我如何在Java中更新Sqlite结果集.

but still getting the exception, i think it is because we cannot update the result Set using SQLite DB. Please help that how can i update the Sqlite Resultset in java.

推荐答案

如果要获取与实际存储在数据库中的值不同的值,则可以在SQL查询本身中进行这些更改. 在最一般的情况下,您可以使用 CASE表达式:

If you want to get different values than those actually stored in the database, you can do these changes in the SQL query itself. In the most general case, you can use a CASE expression:

SELECT ID,
       Name,
       [...],
       CASE Status
         WHEN 'A' THEN 'active'
         WHEN 'D' THEN 'inactive'
         ELSE          'whatever'
       END AS Status
FROM MyTable

这篇关于如何在Java中的Sqlite中更新ResultSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆