简体   繁体   中英

com.microsoft.sqlserver.jdbc.sqlserverexception: the parameter number 1 is not valid

Using JDBC SQL driver, I receive the following error:

com.microsoft.sqlserver.jdbc.sqlserverexception: the parameter number 1 is not valid.

The relevant code is as follows:

CallableStatement preparedCall;
String sql = "{call [dbo].[my_sproc] (?) }";
preparedCall = conn.prepareCall(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

DBLookup.setObject(preparedCall, 1, "Some value");

ParameterMetaData pmd = ps.getParameterMetaData();
int parameterType = pmd.getParameterType(1); //<-- here is where it's thrown

This can be caused by the connecting user credentials not having appropriate access to the stored procedure in SQL Server.

Grant EXECUTE permissions and this should be resolved.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM