此程序都是企业级 的数据库开发程序 全面揭示了JAVA对数据库的操作

源代码在线查看: maxrows.java

软件大小: 1269 K
上传用户: zbcs1025
关键词: JAVA 程序 数据库 企业级
下载地址: 免注册下载 普通下载 VIP

相关代码

				package results;
				
				import java.sql.*;
				import connections.*;
				
				public class MaxRows {
				  public static void main(String[] args) {
				    Connection conn = null;
				    Statement stmt = null;
				    ResultSet rset = null;
				
				    try {
				      conn = ConnectionFactory.getConnection();
				      stmt = conn.createStatement();
				      rset = stmt.executeQuery("SELECT * FROM tracks");
				
				      int count = 0;
				      while (rset.next()) {
				        count++;
				      }
				      System.out.println("Unconstrained query returned " + count + " rows");
				
				      stmt.setMaxRows(5);
				      rset = stmt.executeQuery("SELECT * FROM tracks");
				
				      count = 0;
				      while (rset.next()) {
				        count++;
				      }
				      System.out.println("Constrained query returned " + count + " rows");
				
				    } catch (Exception e) {
				      e.printStackTrace();
				    } 
				    finally {
				      ConnectionFactory.close(rset);
				      ConnectionFactory.close(stmt);
				      ConnectionFactory.close(conn);
				    }
				  }
				}			

相关资源