以下のコードを実行すると、プロパティ "sql" is required エラーが発生します。誰かが私を助けることができますか?Datasource を TestDAO calss に挿入して正しく動作させる方法がわかりません。
public class TestDAO extends BaseStoredProcedure
{
final protected Logger logger = Logger.getLogger(this.getClass().getName());
private static final String SPROC_NAME = "dbo.SP1";
@Autowired
private JdbcTemplate jdbcTemplate;
public java.util.ArrayList<IssuerProductResponse> validIssuersProducts(java.util.ArrayList<IssuerProductRequest> issuersProducts)
{
//PARAM MAP set here
//compile SP
HIOSBaseStoredProcedure hiosBaseSP = new HIOSBaseStoredProcedure(jdbcTemplate.getDataSource(),SPROC_NAME,inMap,null,null,null);
//now set parameters
Map<String, Object> result = super.execute(parameters);
System.out.println(result);
return liReponse;
}
}
BaseStoreProcedure クラス
public class BaseStoredProcedure extends StoredProcedure {
public BaseStoredProcedure() {
super();
// TODO Auto-generated constructor stub
}
/**
*
* @param ds
* @param spname
* @param map
* @param sqlOutKey
* @param returnType
* @param rowmapper
*/
public BaseStoredProcedure (DataSource ds, String spname,
Map<String, Integer> map, String sqlOutKey, Integer returnType,
RowMapper rowmapper) {
super();
setDataSource(ds);
/* resultset has to be declared first over other declare parameters */
if (rowmapper != null) {
declareParameter(new SqlReturnResultSet(sqlOutKey, rowmapper));
}
if (map != null) {
Iterator itr = map.keySet().iterator();
while (itr.hasNext()) {
String key = (String) itr.next();
Integer value = (Integer) map.get(key);
declareParameter(new SqlParameter(key, value.intValue()));
}
}
/*
* sql out paramter has to be declared based on the order in stored
* procedures, In all our stored procedures we have it after input
* parameters
*/
if (returnType != null) {
declareParameter(new SqlOutParameter(sqlOutKey, returnType
.intValue()));
}
setSql(spname);
compile();
}
}
春の構成
<bean id="dao" class="test.dao.TestDAO"> <property name="jdbcTemplate" ref="jdbcTemplate"></property> </bean>
<bean id="baseSP" class="test.dao.BaseStoredProcedure"> </bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /> <property name="url" value="jdbc:sqlserver://IP:1433;databaseName=DB;" /> <property name="username" value="username" /> <property name="password" value="password" /> <property name="validationQuery" value="SELECT 1" /> <property name="initialSize" value="1"/> <property name="maxActive" value="20"/> </bean>