⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e299. getting an object value from an oracle table.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
This example retrieves values contained in an Oracle OBJECT type. The example uses the table and types created in e296 Creating an OBJECT Type in an Oracle Database. 
    try {
        // Create a statement
        Statement stmt = connection.createStatement();
    
        // Select rows from object1_table
        ResultSet resultSet = stmt.executeQuery("SELECT * FROM object1_table");
    
        // Get the OBJECT values from each row
        while (resultSet.next()) {
            // Get the integer from the first column col_integer of the row
            int i = resultSet.getInt(1);
    
            // Get the object1 value from the second column col_object1
            oracle.sql.STRUCT object1 = (oracle.sql.STRUCT)resultSet.getObject(2);
    
            // Get the object1 values from each row
            Object[] object1Values = object1.getAttributes();
    
            // Get the first value of object1, which is a string
            String str = (String)object1Values[0];
    
            // Get the second value of object1, which is of the type object2
            oracle.sql.STRUCT object2 = (oracle.sql.STRUCT)object1Values[1];
    
            // Get the values of object2
            Object object2Values[] = object2.getAttributes();
            str = (String)object2Values[0];
            BigDecimal num =  (BigDecimal)object2Values[1];
        }
    } catch (SQLException e) {
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -