SQLiteJDBC 和PreparedStatement 使用pragma table_info
我正在利用 Java 和 SQLiteJDBC 来处理 SQLite。我需要访问给定表的列名,我发现可以使用以下命令来完成此操作:
pragma table_info(myTable)
但是,当尝试执行以下操作时,我收到错误。
PreparedStatement _pstmt =
this._DBConnection.prepareStatement("pragma table_info( '?' );",
new String[] {_tableName} );
java.sql.SQLException:NYI
我不知道 NYI 是什么意思,而且,我不确定我是否可以做我想做的事情。关于如何完成获取列名称有什么建议吗?
I'm utilizing Java and SQLiteJDBC to work with SQLite. I need to access name of columns for a given table and I've found that I could accomplish this with the following command:
pragma table_info(myTable)
However, when attempting to do the following I get an error.
PreparedStatement _pstmt =
this._DBConnection.prepareStatement("pragma table_info( '?' );",
new String[] {_tableName} );
java.sql.SQLException: NYI
I have no idea what NYI means and furthermore, I'm not sure if I can do what I'm trying to do. Any suggestions on how I can accomplish getting the column names?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NYI 的意思是“尚未实施”。
我猜想命令“pragma table_info”可能无法直接作为准备好的语句执行。
有一个在 SQLite JDBC 驱动程序代码中执行该 pragma 语句的示例,类 org.sqlite.Metadata,诸如
getColumns()
和getPrimaryKeys()
之类的方法。我无法摘录代码并将其发布到此处,因为这样做与 StackOverflow 使用的知识共享许可证不兼容。因此,请访问该链接并查看。
NYI means "not yet implemented."
I would guess that the command "pragma table_info" probably can't be executed directly as a prepared statement.
There's an example of executing that pragma statement in the code for the SQLite JDBC driver, class org.sqlite.Metadata, methods such as
getColumns()
andgetPrimaryKeys()
.I can't excerpt the code and post it here, because doing so would not be compatible with the Creative Commons license used by StackOverflow. So please go to that link and take a look.
下面是 SQLiteJDBC 源代码 的代码摘录:
我猜 NYI 的意思是“尚未实施”。
如果编译指示不起作用,
您可以从 sqlite_master 表中获取实际的列定义并自行解析它们。
There's this excerpt of code from SQLiteJDBC source code:
I'm guessing NYI means "Not Yet Implemented".
If the pragma thing isn't working out,
You can grab the actual column definitions from the
sqlite_master
table and parse them out yourself.