当前位置: 技术问答>java相关
数据库问题!!
来源: 互联网 发布时间:2015-10-23
本文导语: 我的原程序是 错误代码是 D:Program FilesApache GroupTomcat 4.1workStandalonelocalhosttestdatabaseconnecttest_jsp.java:61: 不兼容的类型 发现:int 需要:java.sql.ResultSet ResultSet rs=stmt.executeUpdate("Create table li(ID INTEGER)"); ...
我的原程序是
错误代码是
D:Program FilesApache GroupTomcat 4.1workStandalonelocalhosttestdatabaseconnecttest_jsp.java:61: 不兼容的类型
发现:int
需要:java.sql.ResultSet
ResultSet rs=stmt.executeUpdate("Create table li(ID INTEGER)");
^
1 个错误
请问我应如何办?
|
executeUpdate
public int executeUpdate(String sql)
throws SQLException
Executes an SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing, such as SQL DDL statements, can be executed.
Parameters:
sql - an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing
Returns:
either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
public int executeUpdate(String sql)
throws SQLException
Executes an SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing, such as SQL DDL statements, can be executed.
Parameters:
sql - an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing
Returns:
either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
|
stmt.executeUpdate("Create table li(ID INTEGER)");
的返回值是int型的
的返回值是int型的
|
stmt.executeUpdate方法返回的是整数类型,
ResultSet rs=stmt.executeUpdate这样当然会报错了,
你可以,int intResult = stmt.executeUpdate("Create table li(ID INTEGER)");
当intResult=-1时表示招待失败。
ResultSet rs=stmt.executeUpdate这样当然会报错了,
你可以,int intResult = stmt.executeUpdate("Create table li(ID INTEGER)");
当intResult=-1时表示招待失败。
|
你看一看下面:
executeUpdate
public int executeUpdate(String sql)
throws SQLExceptionExecutes an SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing, such as SQL DDL statements, can be executed.
Parameters:
sql - an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing
Returns:
either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
Throws:
SQLException - if a database access error occurs
明白了吧!
executeUpdate
public int executeUpdate(String sql)
throws SQLExceptionExecutes an SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing, such as SQL DDL statements, can be executed.
Parameters:
sql - an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing
Returns:
either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
Throws:
SQLException - if a database access error occurs
明白了吧!