I have access to a stored procedure on a sql server which has one parameter and I can easily run it on the sql client as follow:
exec sp_name "2016/11/01"
Now I want to do the same thing in java.
PreparedStatement ps = conn.prepareStatement("sp_name ?");
ps.setString(1, "2016/11/01");
ResultSet rs = ps.executeQuery();
In rs
I can see the columns' names, but zero row is returned. I think it is because of the stored procedure's parameter. Am I missing something here?
Here is the code that worked eventually:
String date= "2016/11/01"
String queryString "exec sp_dmp_pub_status ?";
PreparedStatement ps = conn.prepareStatement(queryString);
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
Date parsed = format.parse(date);
java.sql.Date sqlDate = new java.sql.Date(parsed.getTime());
ps.setDate(1, sqlDate);
ResultSet rs = ps.executeQuery();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.