我已經......我使用的騾子JDBC和下面的配置,我主持使用騾子... web服務檢索MS SQL數據庫中數據的Web服務: -如何使用騾子
<context:property-placeholder location="classpath:conf/DBConnectionProp.properties"/>
<spring:beans>
<spring:bean id="DB_Source" name="DB_Source" class="org.enhydra.jdbc.standard.StandardDataSource">
<spring:property name="url" value="${url}"/>
<spring:property name="driverName" value="${driverName}"/>
</spring:bean>
<spring:bean id="LookUp" name="LookUp" class="com.test.MainDataDAOImpl">
<spring:property name="dataSource" ref="DB_Source"/>
</spring:bean>
</spring:beans>
<jdbc-ee:connector name="Database_Global" dataSource-ref="DB_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
<!-- <jdbc-ee:query key="RetriveQuery" value="Select * from getData where ID=?"/> -->
<jdbc-ee:query key="RetriveQuery" value="CALL sp_myStoredProcedure(?) "/>
</jdbc-ee:connector>
<flow name="MuleDbInsertFlow1" doc:name="MuleDbInsertFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/>
<cxf:jaxws-service service="MainData" serviceClass="com.test.MainData" doc:name="SOAPWithHeader" />
<component class="com.test.MainDataImpl" doc:name="JavaMain_ServiceImpl"/>
</flow>
現在由於我使用存儲過程sp_myStoredProcedure我得到異常(?): -
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [CALL sp_myStoredProcedure(?) ]; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'.
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:714)
at com.vertu.services.schema.maindata.v1.Dao.MainDataDAOImpl.retrieveFromDBMethod(MainDataDAOImpl.java:102)
at com.vertu.services.schema.maindata.v1.Impl.MainDataImpl.retrieveDataOperation(MainDataImpl.java:73)
但是,如果使用普通的SQL查詢: - Select * from getData where ID=?
它工作正常,沒有任何問題......在我的DAOImpl課程是我們的荷蘭國際集團下面的代碼: -
String retrieveDataFromDB = getQueryByKey("RetriveQuery");
jdbcTemplate.query(retrieveDataFromDB, new Object[] { ID },
new RowMapper() {
@Override
public Object mapRow(ResultSet rs, int line)
throws SQLException {
System.out.println("inside row mapper");
// Display records
dataResponse.setId(rs.getInt("ID"));
dataResponse.setName(rs.getString("NAME"));
dataResponse.setAge(rs.getInt("AGE"));
dataResponse.setDesignation(rs
.getString("DESIGNATION"));
dataResponse
.setResponse("The Data retrieved from the Database");
return 1;
}
});
請幫助...什麼是存儲過程的問題,即是正常的SQL查詢工作正常參數???
請停止碰撞你的問題,否則我們將被迫將其鎖定,這將阻止它完全得到答案。 – BoltClock
什麼問題? –
問題是,反覆碰撞您的問題是具有破壞性和不考慮的。 – BoltClock