[英]JDBC Statement interface - executeUpdate query
import java.sql.*;
class ConnectionTest {
public static void main(String... args)throws Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("Jdbc:Odbc:myjdbc1", "sri", "tiger");
System.out.println(con);
Statement st = con.createStatement();
System.out.println(st);
String query = "delete logindetails";
int count = st.executeUpdate(query);
if(count == 0)
System.out.println("no records to delete");
else
System.out.println("deleted successfullly");
con.close();
}
}
Hello World..!! 你好,世界..!! My Question is.. What value is being assigned to integer variable
count
in int count = st.executeUpdate(query);
我的问题是..在
int count = st.executeUpdate(query);
为整数变量count
分配了什么值int count = st.executeUpdate(query);
What does it assigns after it deleted all the rows.. 删除所有行后它分配了什么..
and what does it assigns if there are already 0 rows in my table and no rows are deleted..? 如果我的表中已有0行并且没有删除任何行,它会分配什么?
Detailed explanation is much appreciated. 非常感谢详细的解释。
PS noob here PS noob在这里
From official docs : Returns: either the row count for SQL Data Manipulation Language (such as INSERT, UPDATE or DELETE) statements or 0 for SQL statements that return nothing 来自官方文档 :返回:SQL数据操作语言(例如INSERT,UPDATE或DELETE)语句的行数或0表示不返回任何内容的SQL语句
@Update @Update
It assigns the number of deleted rows. 它指定已删除行的数量。
executeUpdate(query)返回受影响的行数,这意味着如果表中没有行,那么将返回0,如果表中有行,那么表的总行数。
Returns: either 返回:要么
(1) the row count for SQL Data Manipulation Language (DML) statements or (1) SQL数据操作语言(DML)语句的行数或
(2) 0 for SQL statements that return nothing (2) 0表示没有返回任何内容的SQL语句
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.