java - ArrayDescriptor 是线程安全的吗?

标签 java oracle jdbc thread-safety

oracle.sql.ArrayDescriptor 的实例是线程安全的吗?

API http://docs.oracle.com/cd/E16338_01/appdev.112/e13995/oracle/sql/ArrayDescriptor.html因为这个类没有提到任何关于线程安全的内容。

最佳答案

正在运行 javap命令 oracle.sql.ArrayDescriptor类..可以观察到oracle.sql.ArrayDescriptor的公共(public)方法都没有类是同步的。这是 javap 告诉的内容:

E:\users>javap oracle.sql.ArrayDescriptor
Compiled from "ArrayDescriptor.java"
public class oracle.sql.ArrayDescriptor extends oracle.sql.TypeDescriptor implem
ents java.io.Serializable{
    public static final int TYPE_VARRAY;
    public static final int TYPE_NESTED_TABLE;
    public static final int CACHE_NONE;
    public static final int CACHE_ALL;
    public static final int CACHE_LAST;
    static final long serialVersionUID;
    public static final boolean TRACE;
    public static final boolean PRIVATE_TRACE;
    public static final java.lang.String BUILD_DATE;
    public static oracle.sql.ArrayDescriptor createDescriptor(java.lang.String, java.sql.Connection) throws java.sql.SQLException;
    public static oracle.sql.ArrayDescriptor createDescriptor(java.lang.String, java.sql.Connection, boolean, boolean) throws java.sql.SQLException;
    public static oracle.sql.ArrayDescriptor createDescriptor(oracle.sql.SQLName,  java.sql.Connection) throws java.sql.SQLException;
    public static oracle.sql.ArrayDescriptor createDescriptor(oracle.sql.SQLName, java.sql.Connection, boolean, boolean) throws java.sql.SQLException;
    public static oracle.sql.ArrayDescriptor createDescriptor(oracle.jdbc.oracore.OracleTypeCOLLECTION) throws java.sql.SQLException;
    public oracle.sql.ArrayDescriptor(java.lang.String, java.sql.Connection) throws java.sql.SQLException;
    public oracle.sql.ArrayDescriptor(oracle.sql.SQLName, java.sql.Connection) throws java.sql.SQLException;
    public oracle.sql.ArrayDescriptor(oracle.sql.SQLName, oracle.jdbc.oracore.OracleTypeCOLLECTION, java.sql.Connection) throws java.sql.SQLException;
    public oracle.sql.ArrayDescriptor(oracle.jdbc.oracore.OracleTypeCOLLECTION, java.sql.Connection) throws java.sql.SQLException;
    static oracle.sql.ArrayDescriptor createDescriptor(oracle.sql.SQLName, byte[], int, byte[], byte[], oracle.jdbc.internal.OracleConnection, byte[]) throws java.sql.SQLException;
    public int getBaseType() throws java.sql.SQLException;
    public java.lang.String getBaseName() throws java.sql.SQLException;
    public oracle.jdbc.oracore.OracleTypeCOLLECTION getOracleTypeCOLLECTION();
    public int getArrayType() throws java.sql.SQLException;
    public long getMaxLength() throws java.sql.SQLException;
    public java.lang.String descType()  throws java.sql.SQLException;
    java.lang.String descType(java.lang.StringBuffer, int) throws java.sql.SQLException;
    int toLength(oracle.sql.ARRAY) throws java.sql.SQLException;
    byte[] toBytes(oracle.sql.ARRAY, boolean) throws java.sql.SQLException;
    oracle.sql.Datum[] toOracleArray(oracle.sql.ARRAY, long, int, boolean) throws java.sql.SQLException;
    java.lang.Object[] toJavaArray(oracle.sql.ARRAY, long, int, java.util.Map, boolean) throws java.sql.SQLException;
    public java.sql.ResultSet toResultSet(oracle.sql.ARRAY, long, int, java.util.Map, boolean) throws java.sql.SQLException;
    public java.sql.ResultSet toResultSet(oracle.sql.Datum[], long, int, java.util.Map) throws java.sql.SQLException;
    public java.sql.ResultSet toResultSetFromLocator(byte[], long, int, java.util.Map) throws java.sql.SQLException;
    public java.sql.ResultSet toResultSetFromImage(oracle.sql.ARRAY, long, int, java.util.Map) throws java.sql.SQLException;
    public static java.lang.Object[] makeJavaArray(int, int) throws java.sql.SQLException;
    oracle.sql.Datum[] toOracleArray(java.lang.Object, long, int) throws java.sql.SQLException;
    java.lang.Object toNumericArray(oracle.sql.ARRAY, long, int, int, boolean) throws java.sql.SQLException;
    public int getTypeCode() throws java.sql.SQLException;
    public byte[] toBytes(oracle.sql.Datum[]) throws java.sql.SQLException;
    public byte[] toBytes(java.lang.Object[]) throws java.sql.SQLException;
    public int length(byte[]) throws java.sql.SQLException;
    public oracle.sql.Datum[] toArray(byte[]) throws java.sql.SQLException;
    public oracle.sql.Datum[] toArray(java.lang.Object) throws java.sql.SQLException;
    public java.sql.ResultSet toResultSet(byte[], java.util.Map) throws java.sql.SQLException;
    public java.sql.ResultSet toResultSet(byte[], long, int, java.util.Map) throws java.sql.SQLException;
    public static int getCacheStyle(oracle.sql.ARRAY) throws java.sql.SQLException;
    static {};
}

因此您应该继续使用此类,假设它不是线程安全的。

更新
根据您的说法,由于该类的所有私有(private)和公共(public)变量都是最终变量,因此实例的内部状态无法通过其方法进行更改。但是oracle.sql.ArrayDescriptor也继承oracle.sql.TypeDescriptor其中包含非最终变量,如下所示:

E:\users>javap -private oracle.sql.TypeDescriptor
Compiled from "TypeDescriptor.java"
public abstract class oracle.sql.TypeDescriptor extends java.lang.Object implements java.io.Serializable{
    public static boolean DEBUG_SERIALIZATION;
    static final long serialVersionUID;
    oracle.sql.SQLName sqlName;
    oracle.jdbc.oracore.OracleNamedType pickler;
    transient oracle.jdbc.internal.OracleConnection connection;
    private static final java.lang.String _Copyright_2004_Oracle_All_Rights_Reserved_;
    public static final boolean TRACE;
    public static final boolean PRIVATE_TRACE;
    public static final java.lang.String BUILD_DATE;
    protected oracle.sql.TypeDescriptor();
    protected oracle.sql.TypeDescriptor(java.lang.String, java.sql.Connection)throws java.sql.SQLException;
    protected oracle.sql.TypeDescriptor(oracle.sql.SQLName, java.sql.Connection)throws java.sql.SQLException;
    protected oracle.sql.TypeDescriptor(oracle.sql.SQLName, oracle.jdbc.oracore.OracleTypeADT, java.sql.Connection)throws java.sql.SQLException;
    protected oracle.sql.TypeDescriptor(oracle.jdbc.oracore.OracleTypeADT, java.sql.Connection)throws java.sql.SQLException;
    public synchronized java.lang.String getName() throws java.sql.SQLException;
    public synchronized oracle.sql.SQLName getSQLName() throws java.sql.SQLException;
    void initSQLName()       throws java.sql.SQLException;
    public java.lang.String getSchemaName()       throws java.sql.SQLException;
    public java.lang.String getTypeName()       throws java.sql.SQLException;
    public oracle.jdbc.oracore.OracleNamedType getPickler();
    public oracle.jdbc.internal.OracleConnection getInternalConnection();
    public void setPhysicalConnectionOf(java.sql.Connection);
    public abstract int getTypeCode()       throws java.sql.SQLException;
    public static oracle.sql.TypeDescriptor getTypeDescriptor(java.lang.String,oracle.jdbc.OracleConnection) throws java.sql.SQLException;
    public static oracle.sql.TypeDescriptor getTypeDescriptor(java.lang.String,oracle.jdbc.OracleConnection, byte[], long) throws java.sql.SQLException;
    public boolean isInHierarchyOf(java.lang.String) throws java.sql.SQLException;
    private void writeObject(java.io.ObjectOutputStream)throws java.io.IOException;
    private void readObject(java.io.ObjectInputStream)throws java.io.IOException, java.lang.ClassNotFoundException;
    public void setConnection(java.sql.Connection) throws java.sql.SQLException;
    public static java.lang.String getSubtypeName(oracle.jdbc.OracleConnection,byte[], long) throws java.sql.SQLException;
    public void initMetadataRecursively()       throws java.sql.SQLException;
    public void initNamesRecursively()       throws java.sql.SQLException;
    public void fixupConnection(oracle.jdbc.internal.OracleConnection) throws java.sql.SQLException;
    public java.lang.String toXMLString()       throws java.sql.SQLException;
    public void printXML(java.io.PrintStream)       throws java.sql.SQLException;
    void printXML(java.io.PrintWriter, int)       throws java.sql.SQLException;
    void printXMLHeader(java.io.PrintWriter)       throws java.sql.SQLException;
    static {};
}

因此,这些非最终变量有可能会因访问 oracle.sql.ArrayDescriptor 的同一对象的不同线程而发生不可预测的变化。类(class)。所以我仍然认为它不是Thread-safe .

关于java - ArrayDescriptor 是线程安全的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15706026/

相关文章:

java - 使用 asadmin 在 glassfish 上创建具有默认属性的 jdbc 连接池

java - mysql按 hibernate 中的字段等效排序

java - 不打印链表的完整内容

java - "When a Class is loaded"到底是什么意思?

java - 如何将父表和子表数据移动到存档表(具有相同的列)

sql - 如何用正则表达式检查oracle中表的所有列名?

java - 玩! JPA 和 GroupBy 框架

sql - 如何显示较大金额的值(value)

java - 如何从结果集中获得双倍而不是双倍?

java - 找不到 Gerrit JDBC 驱动程序