Announcement Announcement Module
Collapse
No announcement yet.
Property Sql is required error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Property Sql is required error

    I am getting property "sql" is required error when i execute below code. can someone help me? i dont know how do i inject Datasource in TestDAO calss so that it works properly.

    Code:
    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;
        }
    
    
    }
    Code:
    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();
        }
    }
    HTML Code:
    <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>
Working...
X