java中STRUCT的数据类型是什么?

时间:2014-08-07 23:48:43

标签: java arrays type-conversion

我今天看到了一个已经写好的旧java代码,它有这些代码:

  STRUCT accDetail = new STRUCT(t_account_details, conn, itemAttributes);
  STRUCT[] accDetails = {accDetail};

这个STRUCT是什么类型的数据类型?

由于

5 个答案:

答案 0 :(得分:4)

这只是一个普通的Java类,有人选择了一个奇怪的名字。看看你是否有任何文档,或者IDE是否识别它,因为看到你的问题的人不太可能知道这个类。

答案 1 :(得分:1)

在这种情况下,STRUCT似乎是一个命名不好的类。类通常命名如下:

“类名应该是名词,大小写混合,每个内部单词的首字母大写。尽量保持你的类名简单和描述。使用整个单词 - 避免缩略语和缩写(除非缩写更广泛使用而不是长格式,如URL或HTML)。“

有关详细信息,请参阅Naming Conventions

根据Noman K的评论,请参阅(http://docs.oracle.com/cd/E18283_01/appdev.112/e13995/oracle/sql/STRUCT.html#STRUCT_oracle_sql_StructDescriptor__java_sql_Connection__java_util_Map_

public STRUCT(StructDescriptor type,
              java.sql.Connection conn,
              java.lang.Object[] attributes)
       throws java.sql.SQLException

    Constructor. The raw bytes are computed at this time or a copy of attributes is made. In any event the caller is free to modify the array without affecting the values held in the STRUCT. For inherited object types we must check that the descriptor indicates that the type is instantiable. That database does not check on e.g. insertion but only on PL/SQL object creation. So we have to check here, too. There is an argument to be made that there is a good use for the STRUCT instance to carry data around and that the error ought to be when an insertion or udpate is attempted. But this keeps the "not instantiable" rather than "not storable" notion. And is is much more simple.

    Parameters:
        type - the SQLStructType used to convert the type to
        attributes - the array specifying the attributes to be converted to raw bytes.
    Throws:
        java.sql.SQLException
    See Also:
        oracle.sql.SQLStructType

答案 2 :(得分:0)

从代码段判断

STRUCT accDetail = new STRUCT(t_account_details, conn, itemAttributes);
  STRUCT[] accDetails = {accDetail};

STRUCT是STRUCT类型,但它遵循Java命名约定。 STRUCT是使用new关键字和STRUCT构造函数实例化的,这使得它显然是一个类,Java中的所有类都是它们所代表的类型。例如。 String类的类型为String,Date类的类型为Date等。

答案 3 :(得分:0)

如果您使用的是IDE,例如Eclipse,则只需单击STRUCT并按F3。它将带来类定义,您可以使用它来找出类的内容。

但无论如何,这不会像c ++那样。

答案 4 :(得分:0)

根据STRUCT Javadoc,

  
      
  1. 它是通用JDBC Struct接口的Oracle实现类。
  2.   
  3. 它包装Oracle对象类型的“原始字节”。
  4.   

Java使用它通过JDBC与Oracle关系数据库实例进行交互。根据Oracle文档:Working with Oracle Object Types

  

如果您选择不为Oracle对象的SQL-Java映射提供自定义Java类,则Oracle JDBC将该对象实现为oracle.sql.STRUCT类的实例。