我有一个Play 2.4.3应用程序并使用JDBC连接到SQL Server数据库。我只写了一个数据库类来处理调用存储过程。不过,我碰了壁:JDBC SQLServerException参数未定义
我PROC的开始:
ALTER PROCEDURE [WebApp].[Content_GetByAppID]
(
@inAppID int,
@inContentGroupID int = null,
@inContentTypeID int = null,
@inContentStatus char(1) = 'A'
)
AS
这里的类方法我写的准备声明:
private CallableStatement createStatement(Connection inConnection, String inProc, DataMap inParams) throws SQLException{
CallableStatement statement = inConnection.prepareCall("{call" + inProc + "}");
if(inParams != null) {
for(Map.Entry<String,Object> e : inParams.entrySet()){
String name = e.getKey();
Object value = e.getValue();
if(value != null){
if (value instanceof Timestamp){
// Sql does its own time conversion. Let's avoid that
statement.setTimestamp(name, (Timestamp)value, Calendar.getInstance(TimeZone.getTimeZone("GMT")));
} else {
statement.setObject(name, value);
}
} else {
// Pass in Special SQL NUll type if parameter is null
statement.setNull(name, Types.NULL);
}
}
}
return statement;
}
我做与呼叫这个: DataMap params = new DataMap();
params.put("inAppID", Play.application().configuration().getInt("richfoods.app.id"));
params.put("inContentTypeID", typeID);
params.put("inContentGroupID", groupID);
params.put("inContentStatus", status);
List<Content> content = mgContentDB.getList(
"WebApp.Content_GetByAppID(?,?,?,?)",
params);
每当createStatement
声明变量试图设置的参数,我得到这个错误:
com.microsoft.sqlserver.jdbc.SQLServerException: com.microsoft.sqlserver.jdbc.SQLServerException: Parameter inContentTypeID was not defined for stored procedure .
什么造成这种任何想法?
编辑:我觉得有趣的事情要注意的是,该错误不包括过程名称。它不应该吗?那告诉我它找不到proc?
你有SQL连接器在您的项目? –
我正在使用JDBC – BooBailey
您是否已将SQL Server连接器放入您的'project/bin'? –