更新与JDBC SQL数组类型的ResultSet / PostgreSQL的 [英] Updating ResultSets with SQL Array types in JDBC / PostgreSQL

查看:901
本文介绍了更新与JDBC SQL数组类型的ResultSet / PostgreSQL的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用SQL数组类型在PostgreSQL 8.4和JDBC4驱动程序。

I'm trying to use a SQL Array type with PostgreSQL 8.4 and the JDBC4 driver.

我的列定义如下:

nicknames           CHARACTER VARYING(255)[]    NOT NULL

和我想正是如此更新:

row.updateArray("nicknames", 
    connection.createArrayOf("CHARACTER VARYING", p.getNicknames().toArray()));

p.getNicknames()返回列表与LT;弦乐>

但我看到:

org.postgresql.util.PSQLException:
  无法找到服务器阵列类型
  提供的名称字符改变。在
  org.postgresql.jdbc4.AbstractJdbc4Connection.createArrayOf(AbstractJdbc4Connection.java:67)
    在
  org.postgresql.jdbc4.Jdbc4Connection.createArrayOf(Jdbc4Connection.java:21)

org.postgresql.util.PSQLException: Unable to find server array type for provided name CHARACTER VARYING. at org.postgresql.jdbc4.AbstractJdbc4Connection.createArrayOf(AbstractJdbc4Connection.java:67) at org.postgresql.jdbc4.Jdbc4Connection.createArrayOf(Jdbc4Connection.java:21)

不幸的是,似乎是数组类型不被据可查 - 我还没有发现究竟提及如何为PostgreSQL的做到这一点的任何地方:(

Unfortunately, the Array types don't seem to be well documented - I've not found mention of exactly how to do this for PostgreSQL anywhere :(

任何想法?

推荐答案

更改字符改变到VARCHAR。命令行的psql 客户端只接受类型名称字符改变,但JDBC驱动程序不。

Change "CHARACTER VARYING" to "varchar". The command-line psql client accepts the type name "CHARACTER VARYING", but the JDBC driver does not.

org.postgresql.jdbc2.TypeInfoCache 源代码包含了接受类型名称的列表。

The source for org.postgresql.jdbc2.TypeInfoCache contains a list of accepted type names.

考虑的含糊措辞合约<一个组成部分href=\"http://java.sun.com/javase/6/docs/api/java/sql/Connection.html#createArrayOf%28java.lang.String,%20java.lang.Object%5B%5D%29\"><$c$c>createArrayOf():

Consider part of the ambiguously-worded contract for createArrayOf():

的typeName为这可能是名称的特定数据库的名称的内置型,一个用户定义的类型或此数据库支持一个标准的SQL类型

The typeName is a database-specific name which may be the name of a built-in type, a user-defined type or a standard SQL type supported by this database.

我一直以为司机实施者间preT此数据库支持的短语特定于数据库的名称,并表示接受任何你想要的。但是,也许你可以此文件作为对Postgres的JDBC驱动程序的bug。

I always assumed driver implementors interpret the phrases "database-specific name" and "supported by this database" to mean "accept whatever you want". But maybe you could file this as a bug against the Postgres JDBC driver.

祝你好运。

这篇关于更新与JDBC SQL数组类型的ResultSet / PostgreSQL的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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