[英]Retrieving postgresql arrays using JDBC
I have a table like this 我有一张这样的桌子
list | id |
-----------+--------
{930,23} | 1 |
{2012,1} | 2 |
{5943} | 3 |
{6148} | 4 |
{1003} | 5 |
Now, I'd like to use JDBC to retrieve the first column. 现在,我想使用JDBC来检索第一列。 I've learned that we can use java.sql.Array to do that. 我了解到我们可以使用java.sql.Array来做到这一点。 ( http://docs.oracle.com/javase/tutorial/jdbc/basics/array.html#retrieving_array ), but when I declare the Array object like this: ( http://docs.oracle.com/javase/tutorial/jdbc/basics/array.html#retrieving_array ),但是当我像这样声明Array对象时:
import java.sql.Array;
while(rs.next())
Array arr;
It issues a compile error: 它发出编译错误:
[javac] /home/xxx.java:291: error: not a statement
[javac] Array arr;
[javac] ^
[javac] /home/xxx.java:291: error: ';' expected
[javac] Array arr;
[javac] ^
[javac] /home/xxx.java:291: error: not a statement
[javac] Array arr;
[javac] ^
It seems that Java is not recognizing the data type java.sql.Array. 似乎Java没有识别数据类型java.sql.Array。 Anyone knows why? 谁知道为什么? Thanks a lot! 非常感谢!
You should use curly brackets with your while statements: 您应该在while语句中使用大括号:
while (rs.next()) {
Array arr; // Add more code here.
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.