要在Statement对象stmt上执行SELECT语句“select*fromAddress”,可以使用________。
A: stmt.execute("select*fromAddress");
B: stmt.executeQuery("select*fromAddress");
C: stmt.executeUpdate("select*fromAddress");
D: stmt.query("select*fromAddress");
A: stmt.execute("select*fromAddress");
B: stmt.executeQuery("select*fromAddress");
C: stmt.executeUpdate("select*fromAddress");
D: stmt.query("select*fromAddress");
举一反三
- 要执行str="select * from customer"语句,假设Statement对象stmt,执行SQL语句的代码哪个正确? A: stmt.executeQuery(str) B: stmt.executeUpdate(str) C: stmt.executeSelect(str) D: stmt.executeDelete(str)
- 假定已经获得一个数据库连接,使用变量conn来表示。下列语句中能够正确获得结果集的有__1__。(选择两项)[br][/br] A.Statement stmt = conn.createStatement()__2__;[br][/br] ResultSet rs = stmt.executeQuery(“SELECT * FROM STUDENT”);[br][/br] B.Statement stmt = conn.createStatement(“SELECT * FROM STUDENT”);[br][/br] ResultSet rs = stmt.executeQuery()__3__;[br][/br] C.PreparedStatement stmt = conn.prepareStatement()__4__;[br][/br] ResultSet rs = stmt.executeQuery(“SELECT * FROM STUDENT”);[br][/br] D.PreparedStatement stmt = conn.prepareStatement(“SELECT * FROM STUDENT”);[br][/br] ResultSet rs = stmt.executeQuery()__5__;
- 下列代码生成了一个结果集 conn=DriverManager.getConnection(uri,user,password); stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs=stmt.executeQuery("select * from book"); 下面哪项对该rs描述正确
- 在查询数据库中的某个表时,Statement对象要调用( )方法 A: executeUpdate("select * from table1") ; B: executInsert("select * from table1") ; C: executeDelete("select * from table1") ; D: executeQuery("select * from table1") ;
- stmt为Statement对象,执行String sqlStatement = "delete from book where bid='tp1001' ";语句后,删除数据库表的记录需要执行stmt.executeUpdate ( )语句