SQL字串不能為空
阿新 • • 發佈:2020-12-19
WrongArgumentException: SQL String cannot be empty
今天,web頁面寫插入功能時,一直報空指標異常,斷點追蹤發現邏輯沒有出錯啊,反正肯定的是應該是jdbc或者reflect工具類其中一個出錯了,找了好久終於找到了。
原來是,SQL字串不能為空,通過檢查發現,在進行預編譯的時候,將SQL語句賦值為空了
Caused by: com.mysql.cj.exceptions.WrongArgumentException: SQL String cannot be empty at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85) at com.mysql.cj.AbstractPreparedQuery.checkNullOrEmptyQuery(AbstractPreparedQuery.java:163) at com.mysql.cj.jdbc.ClientPreparedStatement.<init>(ClientPreparedStatement.java:216)
**在這裡插入圖片描述
SQL字串加個空格就好了**