jmeter 連接SQLServer執行insert語句時, JDBC Request 報錯:java.lang.NumberFormatException: For input string: ""解決方法


具體報錯:

2020-06-30 16:59:04,466 ERROR o.a.j.t.JMeterThread: Error while processing sampler: 'JDBC Request-insert'.

java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source) ~[?:1.8.0_251]
at java.lang.Long.parseLong(Unknown Source) ~[?:1.8.0_251]
at java.lang.Long.parseLong(Unknown Source) ~[?:1.8.0_251]
at org.apache.jmeter.functions.Random.execute(Random.java:64) ~[ApacheJMeter_functions.jar:5.3]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:135) ~[ApacheJMeter_core.jar:5.3]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:110) ~[ApacheJMeter_core.jar:5.3]
at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:100) ~[ApacheJMeter_core.jar:5.3]
at org.apache.jmeter.modifiers.UserParameters.setValues(UserParameters.java:156) ~[ApacheJMeter_components.jar:5.3]
at org.apache.jmeter.modifiers.UserParameters.process(UserParameters.java:141) ~[ApacheJMeter_components.jar:5.3]
at org.apache.jmeter.threads.JMeterThread.runPreProcessors(JMeterThread.java:950) ~[ApacheJMeter_core.jar:5.3]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:549) ~[ApacheJMeter_core.jar:5.3]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.3]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.3]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]

 

解決方法:

1.查看下insert sql語句中的每個字段值是否正確,我這里是因為參數化了,但是字段參數化有問題,所以導致報錯;問題如下:

 

2,查看下insert操作時,字段的類型是否正確,字段類型轉換是否正確,否則也會報錯,尤其注意date類型的參數化,時間戳比較容易出問題,

可參考:jmeter的時間戳函數使用

https://blog.csdn.net/jocleyn/article/details/83414433

我這里后來改為了:${__time(yyyy-MM-dd HH:mm:ss:SSS,time)}  ,錯誤得以解決


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM