我有一个系统,其中系统连接到GSM网关。系统使用轮询从网关检索数据并保存在数据库中。我不知道出了什么问题,但是当我开始向数据库中插入数据时,就会出现错误。但这并不一致,在将其保存到数据库之前尝试1/10。
*系统每2秒轮询一次
这是我得到的全部错误:
### The error may involve com.beneco.cwms.repository.SmsMapper.insertSmsListTest-Inline
### The error occurred while setting parameters
### SQL: BEGIN END;
### Cause: java.sql.SQLException: ORA-06550: line 4, column 9:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
( begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-06550: line 4, column 9:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
( begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
我尝试在BEGIN和END之后删除分号,也尝试在插入后删除分号,但仍然无法正常工作。我不知道问题是什么。
连接到网关并将数据插入数据库
TG800Connector smsGateway = new TG800Connector(sshHost, sshUser, sshPassword, sshPort);
List<SmsMessage> smsList = smsGateway.getSmsMessages();
List<SmsMessage> smsSendList = smsGateway.getSmsSendMessages();
LOGGER.debug("############### GETING SMS MESSAGES FROM GATEWAY #####################");
try {
smsMapper.insertSmsListTest(smsList);
smsMapper.insertSmsSendList(smsSendList);
LOGGER.debug("############# STORING OF MESSAGES TO DATABASE SUCCESSFULL ################");
}catch(Exception e) {
LOGGER.debug("################ Storing Failed! ######################"+e.getMessage());
}
查询
<insert id="insertSmsListTest" parameterType="map">
BEGIN
<foreach collection="smsList" item="smsmessage" index="index" >
INSERT ALL INTO SMS_MESSAGES (MESSAGE_ID,
SENDER,
SMSC,
PORT_ID,
CONTENT,
RECEIVE_TIME,
HAS_READ,
TYPE_OF_MESSAGE,MESSAGE_STATUS)
SELECT #{smsmessage.messageId}, #{smsmessage.sender}, #{smsmessage.smsc}, #{smsmessage.portId}, #{smsmessage.content}, #{smsmessage.receiveTime}, #{smsmessage.hasRead},#{smsmessage.typeOfMessage},#{smsmessage.messageStatus} from dual
where not exists ( select * from SMS_MESSAGES where message_id = #{smsmessage.messageId});
</foreach>
END
</insert>
请告诉我是否需要其他代码。
你们能帮我吗?我不知道为什么会这样。