Returns:
either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
你把代码贴出来
either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
你把代码贴出来
你做事务控制。在你程序的前面有bug
package bean;import java.sql.*;public class connSQLServer {
String sDBDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=master";
Connection conn=null;
Statement stmt=null;
String user = "sa";
String password = "sa";
public connSQLServer() {
try
{
Class.forName(sDBDriver).newInstance();
}
catch (Exception e) {
System.out.print(e.getMessage());
}
} public ResultSet executeQuery(String sql) {
try {
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
return stmt.executeQuery(sql);
}
catch (SQLException e) {
System.out.print("连接数据库错误!");
return null;
}
} public int executeUpdate(String sql) {
try {
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
return stmt.executeUpdate(sql);
}
catch (SQLException e) {
System.out.print("连接数据库错误!");
return -1;
}
} public void disconn() {
try {
if (stmt != null) {
stmt.close();
stmt=null;
}
if (conn != null) {
conn.close();
conn=null;
}
}
catch (SQLException e) {
System.out.print("关闭数据库对象错误!");
}
}
}
*********************************************************************************
SQL语句,有点难看,但是他能在SQLSERVER中更新
update maint set title='’’’’’’’’’’',author='’’’’’’’',type=5,content=' ’’’’’’’<br><br>’’’’<br><br>’’’’’’’’',time='2003-8-28 8:24:42' where id=29
*****************************************************************************
Statement stmt=conn.createStatement()
现在可以了,呵呵,按照你说的改了一下,pfpf。
能不能给我解释一下那些参数的意义啊?mtou老大!|
好象是使用可更新结果集合来更新数据库表格的行
具体的意思你看看帮助
TYPE_OFRWARD_ONLY 结果集不能滚动
TYPE_SCROLL_INSENSITIVE 结果集可以滚动,但是对数据库的变化不敏感
TYPE_SCROLL_SENSITIVE 结果集可以滚动,并且对数据库的变化敏感第二个参数有两种:
CONCUR_READ_ONLY 结果集不能用于更新数据库
CONCUR_UPDATEBLE 结果集可以用于更新数据库