- 错误1:
java.lang.NullPointerException
at com.nantian.sms.service.CoreOnLineTransactionService.findCoreTransactions(CoreOnLineTransactionService.java:128)
at com.nantian.sms.service.CoreOnLineTransactionService.getCoreRealtimeData(CoreOnLineTransactionService.java:72)
报错位置代码:Long selelct=(Long) selectRepeatNum.get("dictionaryVaule");//字典表中的唯一序列号 //???如果字典中没有dictonaryValue,会报空指针异常
解决方法:暂时为数据库s_dictonary中加入数据acctOnlyFlag,202001131510890
- 错误2:
java.lang.ClassCastException: com.nantian.sms.dao.model.Dictionary cannot be cast to java.util.Map
at com.sun.proxy.$Proxy105.selectDictionaryVaule(Unknown Source)
at com.nantian.sms.service.CoreOnLineTransactionService.findCoreTransactions(CoreOnLineTransactionService.java:127)
at com.nantian.sms.service.CoreOnLineTransactionService.getCoreRealtimeData(CoreOnLineTransactionService.java:72)
错误位置:
Map selectRepeatNum=coreOnLineTransactionMapper.selectDictionaryVaule();
解决方法:
select dictionaryVaule from s_dictionary where dictionaryKey="acctOnlyFlag"
3.错误3;
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
at com.nantian.sms.service.CoreOnLineTransactionService.findCoreTransactions(CoreOnLineTransactionService.java:129)
at com.nantian.sms.service.CoreOnLineTransactionService.getCoreRealtimeData(CoreOnLineTransactionService.java:73)
错误位置:
Long selelct=(Long) selectRepeatNum.get("dictionaryVaule");
解决方法:
Long selelct=Long.parseLong((String) selectRepeatNum.get("dictionaryVaule")) ;
4.错误4:
java.lang.IllegalArgumentException: Cannot format given Object as a Date
at java.text.DateFormat.format(DateFormat.java:310)
at java.text.Format.format(Format.java:157)
at com.nantian.sms.service.CoreOnLineTransactionService.noDuplicateRecord(CoreOnLineTransactionService.java:175)
at com.nantian.sms.service.CoreOnLineTransactionService.findCoreTransactions(CoreOnLineTransactionService.java:134)
at com.nantian.sms.service.CoreOnLineTransactionService.getCoreRealtimeData(CoreOnLineTransactionService.java:73)
错误位置:
String transTime=coreDataRealtime.getS21TXTM().toString();
String customizeTime = "HH:mm:ss";
SimpleDateFormat sdf2 = new SimpleDateFormat(customizeTime);
String customizeTimeFormat=sdf2.format(transTime);
解决方法:
String customizeTimeFormat=sdf2.parse(transTime).toString();(这一步实际是先解析成日期,再转换成字符串)
- 错误5:
java.lang.StringIndexOutOfBoundsException: String index out of range: -4
at java.lang.String.substring(String.java:1960)
at com.nantian.sms.service.CoreOnLineTransactionService.noDuplicateRecord(CoreOnLineTransactionService.java:196)
at com.nantian.sms.service.CoreOnLineTransactionService.findCoreTransactions(CoreOnLineTransactionService.java:134)
at com.nantian.sms.service.CoreOnLineTransactionService.getCoreRealtimeData(CoreOnLineTransactionService.java:73)
错误原因:截取空串造成的
if(cardNumber!=null) {
//如果卡号不为空
cardOrAccount=cardNumber;
System.out.println("cardOrAccount卡号:"+cardOrAccount);
String cutAccount=cardOrAccount.substring(cardOrAccount.length()- 4);//截取账号或卡号后四位
allParas.put("cutAccount",cutAccount);//账号或卡号后四位
allParas.put("cardOrAccount", cardOrAccount);
解决方案:增加判断条件
if(cardNumber!=null&&cardNumber.length()!=0)
原理解释:
判断一个字符串是否为空,首先就要确保他不是null,然后再判断他的长度。
String str = xxx;
if(str != null && str.length() != 0) { }
2020-1-25
- 错误1:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'cardOrAccount' not found. Available parameters are [cardNum, param1]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:79)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447)
at com.sun.proxy.$Proxy102.selectOne(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:167)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
at com.sun.proxy.$Proxy105.selectSignMsg(Unknown Source)
at com.nantian.sms.service.CoreOnLineTransactionService.querySignMsg(CoreOnLineTransactionService.java:442)
at com.nantian.sms.service.CoreOnLineTransactionService.dealCoreData(CoreOnLineTransactionService.java:247)
错误原因:
Map selectSignMsg(@Param("cardNum")String cardOrAccount);
原理解释:
采用#{}的方式把@Param注解括号内的参数进行引用(括号内参数对应的是形参)
解决方案:
Map selectSignMsg(@Param("cardOrAccount")String cardOrAccount);
注意:dao层用map类型接收,需要在mapper.xml文件中声明resultType="map"
例如:
/**
* 查询字典表中dictionaryVaule值
*/
Map selectDictionaryVaule();
select dictionaryVaule from s_dictionary where dictionaryKey="acctOnlyFlag"
- 错误3
错误原因:
org.springframework.dao.DataIntegrityViolationException:
### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'mobile' cannot be null
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into b_sendmsgb(acctOnlyFlag,mobile,msgConent,tradeDate,tradeTime,insertTime,islongMsg) values (?,?,?,?,?,?,?)
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'mobile' cannot be null
; SQL []; Column 'mobile' cannot be null; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'mobile' cannot be null
at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:85)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447)
at com.sun.proxy.$Proxy102.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:279)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:57)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
at com.sun.proxy.$Proxy105.signMsgInsertSendMsgB(Unknown Source)
at com.nantian.sms.service.CoreOnLineTransactionService.querySignMsg(CoreOnLineTransactionService.java:551)
原因分析:
Map signMsgInsertSendMsgB(Map signMsgSaveSendMsgB);
数据封装在了map中,mapper,xml文件中没有遍历取出手机号,导致报手机号不能为空的错误
解决方案:
4.
错误原因:
org.springframework.jdbc.UncategorizedSQLException:
### Error updating database. Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, expect ')' : insert into b_sendmsgb
values
### SQL: insert into b_sendmsgb values
### Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, expect ')' : insert into b_sendmsgb
values
; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; sql injection violation, syntax error: syntax error, expect ')' : insert into b_sendmsgb
values; nested exception is java.sql.SQLException: sql injection violation, syntax error: syntax error, expect ')' : insert into b_sendmsgb
values
- 错误原因5:
org.springframework.jdbc.UncategorizedSQLException:
### Error updating database. Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'le=? from s_dictionary where
dict',expect FROM, actual FROM from : update dictionaryVaule set
dictionaryVaule=? from s_dictionary where
dictionaryKey="acctOnlyFlag"
### SQL: update dictionaryVaule set dictionaryVaule=? from s_dictionary where dictionaryKey="acctOnlyFlag"
### Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'le=? from s_dictionary where
dict',expect FROM, actual FROM from : update dictionaryVaule set
dictionaryVaule=? from s_dictionary where
dictionaryKey="acctOnlyFlag"
; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; sql injection violation, syntax error: syntax error, error in :'le=? from s_dictionary where
dict',expect FROM, actual FROM from : update dictionaryVaule set
dictionaryVaule=? from s_dictionary where
dictionaryKey="acctOnlyFlag"; nested exception is java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'le=? from s_dictionary where
dict',expect FROM, actual FROM from : update dictionaryVaule set
dictionaryVaule=? from s_dictionary where
dictionaryKey="acctOnlyFlag"
解决方案:自己的sql写的有问题
2010-1-28
- 没有找到短信模板处理方式:
- 错误1: