这更像是一个效率问题:在Android应用程序中执行JDBC时,我应该在存储过程中使用preparecall或createstatement吗?下面是我的代码中调用存储过程并运行的方法示例:
public static ResultSet getUserNames (String userid) {
ResultSet rs = null;
try {
cstmt = con.prepareCall("{call dbo.StoredProcedure(?)}");
cstmt.setString("@ID", userid);
cstmt.setQueryTimeout(10);
rs = cstmt.executeQuery();
return rs;
} catch (Exception e) {
Log.e("DB Error:", e.getMessage());
return null;
}
}