修改id为3的学生成绩为100,其中id为bigint类型 String sql="update student set math=100 where id=?"; PreparedStatement pstmt=con.prepareStatement(sql); 下列语句正确的是()
A: pstmt.setLong(1,3); pstmt.executeUpdate();
B: pstmt.setInt(1,3); pstmt.executeUpdate();
C: pstmt.setLong(1,3L); pstmt.executeQuery();
D: pstmt.setLong(1,3L); pstmt.executeUpdate();
A: pstmt.setLong(1,3); pstmt.executeUpdate();
B: pstmt.setInt(1,3); pstmt.executeUpdate();
C: pstmt.setLong(1,3L); pstmt.executeQuery();
D: pstmt.setLong(1,3L); pstmt.executeUpdate();
举一反三
- 下列选项中,可得到 PreparedStatement对象的是( ) A: PreparedStatement pstmt =connection.createStatement(); B: PreparedStatement pstmt =connection.prepareStatement(sql); C: PreparedStatement pstmt =connection.prepareStatement(); D: PreparedStatement pstmt = connection.createStatement("sql");
- 智慧职教: 现在预编译语句对象为pstmt,如果为下列预编译SQL的第二个问号赋值为abc123,那么正确的选项是( )。 SELECT * FROM users where uname=? and pwd=?; 其中:uname是用户姓名,pwd是密码。
- 给定如下Java代码片段,假定已经获得一个数据库连接,使用变量conn来表示。要从表FirstLevelTitle中删除所有creeator列值为“张三”的记录(creator字段的数据类型为varchar),可以填入下划线处的代码是( )。[br][/br]String strSql =”delete from FirstLevelTitle where creator = ?”;[br][/br]preparedStatement pstmt = con.prepareStatement(strSql);[br][/br]_________[br][/br]Pstmt. executeUpdate (); A: pstmt.setString(0,”张三”); B: pstmt.setString(1,”张三”); C: pstmt.setInt(0,”张三”); D: pstmt.setInt(1,”张三”);
- 把student表中id字段值小于3的记录,将这些记录的grade字段值都更新为100() A: UPDATE FROM student SET grade=100 where id<;3 B: UPDATE student SET grade=100 where id<;3 C: UPDATE student SET grade=100 D: UPDATE INTO student SET grade=100 where id<;3
- 更新student表id=1的记录,name值更新为”youjun”,grade值更新为98.5,下列选项中,能够完成上述功能的SQL语句是 A: UPDATE student set name=’youjun’ grade=98.5 where id=1; B: UPDATE student set name=’youjun’, grade=98.5 where id=1; C: UPDATE FROM student set name=’youjun’ ,grade=98.5 where id=1; D: UPDATE student Values name=’youjun’ grade=98.5 where id=1;