我在 java soap 服务上编写了一个操作来查询数据库,然后在客户端 jsp 页面上显示我搜索过的数据。但是,我不能显示它,变量“rs”不能改变,我不知道为什么?有人可以帮我找到麻烦吗?这是我在肥皂服务上创建的操作:
@WebMethod(operationName = "query")
public String query(@WebParam(name = "parameter") String parameter) {
ResultSet rs;
try {
Connection con = data1.getConnection();
Statement statement = con.createStatement();
String QueryString;
QueryString = "SELECT * from stud where name= parameter";
rs = statement.executeQuery(QueryString);
while (rs.next()) {
System.out.println(rs.getInt(1) + " " + rs.getString(2) + "\n");
}
} catch (Exception ex) {
System.out.println("Unable to connect to batabase.");//TODO write your implementation code here:
}
//TODO write your implementation code here:
return null;
}