这里面包含了一百多个JAVA源文件

源代码在线查看: e299. getting an object value from an oracle table.txt

软件大小: 551 K
上传用户: maple_78
关键词: JAVA
下载地址: 免注册下载 普通下载 VIP

相关代码

				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) {
				    }
				
							

相关资源