English 中文(简体)
绘图 PostgreSQL 文本 [ ] 类型和 Java 类型
原标题:Mapping PostgreSQL text[][] type and Java type

我有一个 Postgres 表格, 包含类型为 < code> text [][ 的列。 在 JDBC 代码我曾经使用过字符串阵列, 但有一个例外告诉我这两个阵列不匹配。 如果这些阵列之间没有映射, 您能否为字符串阵列建议 Postgres 类型?

这是代码:

String list = " {";
        for(int i=0; i<array.length; i++) {
            list+=prodotti[i]+",";
        }
        list+="} ";

        preparedStm.setString(4, list);
最佳回答

为理解多维 PostgreSQL 阵列类型,可考虑以下 < a href="https://www.postagresql.org/docs/text/rarys.html#ARRAYS-DELARATION" rel=“nofollow noreferrer" > 引号:

The current implementation does not enforce the declared number of dimensions either. Arrays of a particular element type are all considered to be of the same type, regardless of size or number of dimensions. So, declaring the array size or number of dimensions in CREATE TABLE is simply documentation; it does not affect run-time behavior.

在内部, text[] , text[] text[][] ]的类型与 PostgreSQL. . /strong> 相同。 如果该列实际上包含二维文本阵列, 您必须匹配 Java 的尺寸。 但是它也可以包含一或三维阵列。 PostgreSQL 会允许它 。

还请注意,在PostgreSQL中,text 字符变化 (varchar )是 different data type (在varchar 没有长度修饰者时,数据类型大致相同) 。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...