ConnectionName.createStatement(int type,int concurrency)
参数:Type-----决定了返回的语句在执行查询后的结果记录集,其记录指针移动方式有以下三种值:
ResultSet.TYPE_FORWORD_ONLY:结果集记录指针只能向下移动
ResultSet.Type_SCROLL_INSENSITIVE:结果集记录指针可以上下移动,但数据库内容变化时结果集不变
ResultSet.Type_SCROLL_SENSITIVE:结果集记录指针可以上下移动,当数据库内容发生变化后结果集内容同步改变
Concurrency—决定是否可以用结果记录集更新数据库中的表,有以下两种值:
ResultSet._CONCUR_READ_ONLY:结果记录集为只读,不能更新数据库表中的数据;
ResultSet.CONCUR_UPDATABLE:用结果记录集可以更新数据库表中的数据
ResultSet就是结果集,相当于把数据库中的数据存取到本地机器的缓存中。
分享到:
相关推荐
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return null;} public PreparedStatement prepareStatement(String sql, int ...
在上面的代码中,我们使用 createStatement() 方法创建了一个 Statement 对象,并指定了 ResultSet 的类型为 TYPE_SCROLL_SENSITIVE 和并发性为 CONCUR_UPDATABLE。这意味着我们可以在 ResultSet 中向前和向后移动,...
3. **创建带有类型、并发性和保持性的Statement**:`Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)` - **用途**:创建一个带有特定类型、并发性和保持性的`...
Statement sm = ct.createStatement(); // 查询总记录数 ResultSet rs = sm.executeQuery("SELECT COUNT(*) FROM users"); if (rs.next()) { rowCount = rs.getInt(1); } // 计算总页数 if (rowCount % pageSize...
Statement sqlStmt = sqlCon.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); String strSQL = "select * from etsa"; ResultSet sqlRst = sqlStmt.executeQuery(strSQL); ``...
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); rs=stmt.executeQuery(sql); } catch(SQLException e) { e.printStackTrace(); } return rs; } /...
sqlStmt=sqlCon.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY); //执行SQL语句并获取结果集 String sql=null; String search=""; String ToPage=request....
sqlStmt = sqlCon.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); // 准备SQL语句 strSQL = "select * from person"; // 执行SQL语句并获取结果集 sqlRst = sqlStmt....
sqlStmt = sqlCon.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY); // 准备SQL语句 strSQL = "select * from Orders"; // 执行SQL语句并获取结果集 ...
sqlStmt = sqlCon.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); // SQL查询语句 strSQL = "SELECT user_id, user_name FROM userinfo ORDER BY user_id DESC"; // 执行SQL...
java.sql.Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); String sql = "select * from info;"; ``` 连接到MySQL数据库,执行SQL查询语句,这里查询的是`...
Statement stmt = conn.createStatement(); PreparedStatement pstmt = conn.prepareStatement("INSERT INTO table_name VALUES (?, ?)"); ``` ### 3. 插入数据(Insert) 插入数据时,我们调用`executeUpdate()`...
Statement st = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); // ... 省略具体SQL执行逻辑 } } ``` #### 小结 以上代码展示了如何在Hibernate和JDBC中实现数据...
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); String query = "SELECT * FROM your_table"; ResultSet rs = stmt.executeQuery(query); // 获取...
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet rs = stmt.executeQuery(sql); ``` 通过`Statement`对象执行SQL查询语句,并使用`ResultSet`来...
sqlStmt = sqlCon.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY); // 准备SQL语句 strSQL = "select * from etsa"; // 执行SQL语句并获取结果集 sqlRst = ...
Statement stmt = conn.createStatement(int RSType, int RSConcurrency); ``` - 使用`prepareStatement`方法: ```java PreparedStatement pstmt = conn.prepareStatement(String SQL, int RSType, int ...
sqlStmt = sqlCon.createStatement(); // 获取记录总数 strSQL = "SELECT COUNT(*) FROM guestbook"; sqlRst = sqlStmt.executeQuery(strSQL); // 执行SQL语句并取得结果集 sqlRst.next(); intRowCount = ...
Statement stmt = conn.createStatement(int resultSetType, int resultSetConcurrency); ``` 其中,resultSetType指定ResultSet的类型,可以是ResultSet.TYPE_FORWARD_ONLY、ResultSet.TYPE_SCROLL_INSENSITIVE或...