从 Informix 表中选择 BigSerial 列数据
场景就是这样。用户指定一个数据库表名,系统将检索并显示指定informix数据库表中存储的所有数据。
Class.forName("com.informix.jdbc.IfxDriver");
Connection conn = DriverManager.getConnection(connUrl)
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from an_ifx_table");
an_ifx_table 是用户指定的任何表名称。问题是有一个用 BigSerial 数据类型定义的列。因此,代码总是会抛出异常:
java.sql.SQLException: bigserial
at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3204)
at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3518)
at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2353)
at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2269)
at com.informix.jdbc.IfxSqli.executeStatementQuery(IfxSqli.java:1428)
at com.informix.jdbc.IfxSqli.executeStatementQuery(IfxSqli.java:1401)
at com.informix.jdbc.IfxResultSet.a(IfxResultSet.java:204)
由于系统将从哪个表检索数据将由用户指定,因此我们无法跳过或强制转换具有 BigSerial 数据类型的列。
有什么建议来处理这种情况吗?
The scenario is like that. User will specify a database table name and the system will retrieve and display all the data stored in the specified informix database table.
Class.forName("com.informix.jdbc.IfxDriver");
Connection conn = DriverManager.getConnection(connUrl)
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from an_ifx_table");
The an_ifx_table is any table name specified by user. The problem is there is a column defined with BigSerial data type. So, the code will always throw an exception:
java.sql.SQLException: bigserial
at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3204)
at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3518)
at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2353)
at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2269)
at com.informix.jdbc.IfxSqli.executeStatementQuery(IfxSqli.java:1428)
at com.informix.jdbc.IfxSqli.executeStatementQuery(IfxSqli.java:1401)
at com.informix.jdbc.IfxResultSet.a(IfxResultSet.java:204)
As which table the system is retrieving the data from is going to be specified by user, we can't skip or cast the column with BigSerial data type.
Any suggestion to handle this scenario?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚创建了带有
SERIAL8
列的表,并用一些数据填充了它,我可以从 ResultSet 读取所有数据。也许您的 JDBC 驱动程序很旧?
我使用来自
JDBC.3.50.JC5.tar
的 JDBC 驱动程序。您还可以尝试 JDBC-ODBC 桥接器。安装 Informix ClientSDK,创建 ODBC 源,然后作为驱动程序使用:以及作为
connUrl
:在我的 Windows 计算机上,我使用
clientsdk.3.50.TC5.WIN.zip
,在 Linux 上我使用clientsdk.3.50.UC5.LINUX.tarI have just created table with
SERIAL8
column, filled it with some data and I can read all data from ResultSet.Maybe your JDBC driver is old?
I use JDBC driver from
JDBC.3.50.JC5.tar
. You can also try JDBC-ODBC bridge. Install Informix ClientSDK, create ODBC source and then as driver use:and as
connUrl
:On my Windows machine I use
clientsdk.3.50.TC5.WIN.zip
, and on Linux I useclientsdk.3.50.UC5.LINUX.tar