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

源代码在线查看: movecursor.htm

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

相关代码

				
				
				
				Moving the Cursor in a Scrollable Result Set (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]
				    
				        >
				        Scrollable Result Sets
				             [6 examples]
				            
				
				  e269. Moving the Cursor in a Scrollable Result Set
				
				This example demonstrates the various methods for moving the cursor
				in a scrollable result set.
				
				
				    try {
				        // Create a scrollable result set
				        Statement stmt = connection.createStatement(
				            ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
				        ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table");
				    
				        // Move cursor forward
				        while (resultSet.next()) {
				            // Get data at cursor
				            String s = resultSet.getString(1);
				        }
				    
				        // Move cursor backward
				        while (resultSet.previous()) {
				            // Get data at cursor
				            String s = resultSet.getString(1);
				        }
				    
				        // Move cursor to the first row
				        resultSet.first();
				    
				        // Move cursor to the last row
				        resultSet.last();
				    
				        // Move cursor to the end, after the last row
				        resultSet.afterLast();
				    
				        // Move cursor to the beginning, before the first row.
				        // cursor position is 0.
				        resultSet.beforeFirst();
				    
				        // Move cursor to the second row
				        resultSet.absolute(2);
				    
				        // Move cursor to the last row
				        resultSet.absolute(-1);
				    
				        // Move cursor to the second last row
				        resultSet.absolute(-2);
				    
				        // Move cursor down 5 rows from the current row.  If this moves
				        // cursor beyond the last row, cursor is put after the last row
				        resultSet.relative(5);
				    
				        // Move cursor up 3 rows from the current row.  If this moves
				        // cursor beyond the first row, cursor is put before the first row
				        resultSet.relative(-3);
				    } catch (SQLException e) {
				    }
				
				
				
				
				             Related Examples
				
				
				
				
				e266. 
				    Determining If a Database Supports Scrollable Result Sets
				
				
				
				e267. 
				    Creating a Scrollable Result Set
				
				
				
				e268. 
				    Determining If a Result Set Is Scrollable
				
				
				
				e270. 
				    Getting the Cursor Position in a Scrollable Result Set
				
				
				
				e271. 
				    Getting the Number of Rows in a Table Using a Scrollable Result Set
				
				
				
				
				
				
				
				
				        See also: 
				
				    Batching
				  
				
				
				    Connections
				  
				
				
				    Database Meta Data
				  
				
				
				    Deleting Data
				  
				
				
				    Drivers
				  
				
				
				    Importing and Exporting
				  
				
				
				    Inserting and Updating Data
				  
				
				
				    Oracle OBJECTs
				  
				
				
				    Oracle VARRAYs
				  
				
				
				    Procedures and Functions
				  
				
				
				    Retrieving Data
				  
				
				
				    Tables
				  
				
				
				    Updatable Result Sets
				  
				
				
				
				
				
				
				
				
				
				© 2002 Addison-Wesley.
				   
				
				
				
				
				
				
				
				
							

相关资源