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字符串加个空格就好了**