使用JAVA 访问SQL2005抛出com.microsoft.sqlserver.jdbc.SQLServerException: 该语句没有返回结果集。
语句如下:importjava.sql.*;publicclassTry{/***@paramargs*@throwsSQLException*@throwsClassN...
语句如下:
import java.sql.*;
public class Try {
/**
* @param args
* @throws SQLException
* @throws ClassNotFoundException
*/
public static void main(String[] args) throws SQLException, ClassNotFoundException {
// TODO Auto-generated method stub
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1434;DatabaseName=BookInfo";
String user = "sa",pwd = "123456";
String str= "UPDATE book SET price=price+1" ;
Connection con=DriverManager.getConnection(url, user, pwd);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(str);
rs.close();
stmt.close();
con.close();
}
} 展开
import java.sql.*;
public class Try {
/**
* @param args
* @throws SQLException
* @throws ClassNotFoundException
*/
public static void main(String[] args) throws SQLException, ClassNotFoundException {
// TODO Auto-generated method stub
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1434;DatabaseName=BookInfo";
String user = "sa",pwd = "123456";
String str= "UPDATE book SET price=price+1" ;
Connection con=DriverManager.getConnection(url, user, pwd);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(str);
rs.close();
stmt.close();
con.close();
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询