小编Sti*_*ing的帖子

JDBC插入实数组

我试图将一个真正的数组插入postgresql数组:

表定义是:

String sqlTable = "CREATE TABLE IF NOT EXISTS ccmBlock"
                + "   sampleId             INTEGER,"
                + "   block                REAL[])";
Run Code Online (Sandbox Code Playgroud)

插入是:

String sqlInsert = "INSERT INTO ccmBlock"
                 + "(sampleId, block) VALUES" 
                 + "(?,?)"; 
PreparedStatement preparedStatement = theConnection.prepareStatement(sqlInsert);

preparedStatement.setInt(1, 1); 

Object[] theArray = {.11f, .22f, .33f};
Array a = theConnection.createArrayOf("real", theArray);  
preparedStatement.setArray(2, a); 
Run Code Online (Sandbox Code Playgroud)

我收到一条消息:org.postgresql.util.PSQLException:无法找到提供的名称为real的服务器数组类型.

但是在他们的文档页面上:http: //www.postgresql.org/docs/8.4/static/datatype-numeric.html

表8-2.数字类型

名称StorageSize描述范围

真正的 4字节变精度,不精确的6位十进制数精度

sql arrays postgresql jdbc

3
推荐指数
1
解决办法
2638
查看次数

标签 统计

arrays ×1

jdbc ×1

postgresql ×1

sql ×1