这个压缩包里的都是超级经典的java例子

源代码在线查看: insertobjectoraclepreparedstatement.htm

软件大小: 2381 K
上传用户: sinoarts
关键词: java 超级
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				
				
				Inserting an OBJECT Value into an Oracle Table Using a Prepared Statement (Java Developers Almanac Example)
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				The Java Developers Almanac 1.4
				
				        Order this book from Amazon.
				    
				
				
				
				
				
				
				
				
				
				
				
				
				
								google_ad_client = "pub-6001183370374757";
				google_ad_width = 120;
				google_ad_height = 600;
				google_ad_format = "120x600_as";
				google_ad_channel = "4777242811";
				google_ad_type = "text_image";
				google_color_border = "FFFFFF";
				google_color_bg = "FFFFFF";
				google_color_link = "6666CC";
				google_color_url = "6666CC";
				google_color_text = "000000";
				//-->   
				
				Home
				    >
				    List of Packages
				    >
				
				    
				    java.sql
				         [73 examples]
				    
				        >
				        Oracle OBJECTs
				             [5 examples]
				            
				
				  e298. Inserting an OBJECT Value into an Oracle Table Using a Prepared Statement
				
				This example inserts Oracle OBJECTs into an Oracle table using a
				prepared statement.  The example uses the OBJECT types and table
				created in e296 Creating an OBJECT Type in an Oracle Database.
				
				
				    try {
				        // Create an oracle.sql.STRUCT object to hold the values for object2
				        Object[] object2Values = new Object[]{"str", new BigDecimal(123)};
				        oracle.sql.StructDescriptor structDesc =
				            oracle.sql.StructDescriptor.createDescriptor("OBJECT2", connection);
				        oracle.sql.STRUCT object2 =
				            new oracle.sql.STRUCT(structDesc, connection, object2Values);
				    
				        // Create an oracle.sql.STRUCT object to hold the values for object1
				        Object[] object1Values = new Object[]{"str", object2};
				        structDesc = oracle.sql.StructDescriptor.createDescriptor("OBJECT1", connection);
				        oracle.sql.STRUCT object1 =
				            new oracle.sql.STRUCT(structDesc, connection, object1Values);
				    
				        // Create a prepared statement for insertion into object1_table
				        PreparedStatement ps =
				            connection.prepareStatement("INSERT INTO object1_table VALUES(?,?)");
				    
				        // Set the values to insert
				        ps.setInt(1, 123);
				        ps.setObject(2, object1);
				    
				        // Insert the new row
				        ps.execute();
				    } catch (SQLException e) {
				    }
				
				
				
				
				             Related Examples
				
				
				
				
				e296. 
				    Creating an OBJECT Type in an Oracle Database
				
				
				
				e297. 
				    Inserting an OBJECT Value into an Oracle Table
				
				
				
				e299. 
				    Getting an OBJECT Value from an Oracle Table
				
				
				
				e300. 
				    Deleting an OBJECT Type from an Oracle Table
				
				
				
				
				
				
				
				
				        See also: 
				
				    Batching
				  
				
				
				    Connections
				  
				
				
				    Database Meta Data
				  
				
				
				    Deleting Data
				  
				
				
				    Drivers
				  
				
				
				    Importing and Exporting
				  
				
				
				    Inserting and Updating Data
				  
				
				
				    Oracle VARRAYs
				  
				
				
				    Procedures and Functions
				  
				
				
				    Retrieving Data
				  
				
				
				    Scrollable Result Sets
				  
				
				
				    Tables
				  
				
				
				    Updatable Result Sets
				  
				
				
				
				
				
				
				
				
				
				© 2002 Addison-Wesley.
				   
				
				
				
				
				
				
				
				
							

相关资源