The update operation have the problem when the parameter is set to static can update the database inside the content of the
To use? Is an error, a placeholder, strives for the bosses give directions!
Test source code
Public void updateBook () {
BookDao. UpdateBook (new Book (5, "mxyisdog", "DHXDHXHHH", new BigDecimal (32), 123, 44, "static/images"));
}
Method of bookDao inside
Public int updateBook (Book Book) {
String SQL="update t_book set name=? , the author=? , price=? , the sales=? The stock=? , img_path=? Where id=?" ;
Return the update (SQL, book getName (), book. GetAuthor (), book. GetPrice (), book. GetSales (), book. GetStock (), book. GetImgPath (), the book, getId ());
}
The IDEA of an error log
On March 20, 2020 4:58:52 afternoon com. Alibaba. Druid. Support. Logging. JakartaCommonsLoggingImpl info
Information: {} dataSource - 1 inited
Java. SQL. SQLException: com. Microsoft. Essentially, JDBC. SQLServerException: ', 'near a syntax error, Query, update t_book set name=? , the author=? , price=? , the sales=? The stock=? , img_path=? Where id=? The Parameters: [mxyisdog DHXDHXHHH, 32, 123, 44, static/images, 5]
At org.apache.com mons. Dbutils. QueryRunner. Rethrow (QueryRunner. Java: 542)
At org.apache.com mons. Dbutils. QueryRunner. Update (QueryRunner. Java: 599)
At com. Atguigu. Dao. Impl. BaseDao. Update (BaseDao. Java: 21)
At com. Atguigu. Dao. Impl. BookDaoImpl. UpdateBook (25) BookDaoImpl. Java:
At com. Atguigu. Test. BookDaoImplTest. UpdateBook (BookDaoImplTest. Java: 27)
At sun. Reflect. NativeMethodAccessorImpl. Invoke0 (Native Method)
At sun. Reflect. NativeMethodAccessorImpl. Invoke (NativeMethodAccessorImpl. Java: 62)
At sun. Reflect. DelegatingMethodAccessorImpl. Invoke (43) DelegatingMethodAccessorImpl. Java:
The at Java. Lang. Reflect. Method. Invoke (498) Method. The Java:
The at org. Junit. Runners. Model. FrameworkMethod $1. RunReflectiveCall (FrameworkMethod. Java: 50)
The at org. Junit. Internal. Runners. Model. ReflectiveCallable. Run (ReflectiveCallable. Java: 12)
The at org. Junit. Runners. Model. FrameworkMethod. InvokeExplosively (FrameworkMethod. Java: 47)
The at org. Junit. Internal. Runners. Statements. InvokeMethod. Evaluate (InvokeMethod. Java: 17)
The at org. Junit. Runners. ParentRunner. RunLeaf (ParentRunner. Java: 325)
The at org. Junit. Runners. BlockJUnit4ClassRunner. RunChild (BlockJUnit4ClassRunner. Java: 78)
The at org. Junit. Runners. BlockJUnit4ClassRunner. RunChild (BlockJUnit4ClassRunner. Java: 57)
The at org. Junit. Runners. ParentRunner $3. The run (ParentRunner. Java: 290)
The at org. Junit. Runners. ParentRunner $1. The schedule (ParentRunner. Java: 71)
The at org. Junit. Runners. ParentRunner. RunChildren (ParentRunner. Java: 288)
The at org. Junit. Runners. ParentRunner. Access the $000 (ParentRunner. Java: 58)
At org. Junit. Runners. ParentRunner $2. The evaluate (ParentRunner. Java: 268)
The at org. Junit. Runners. ParentRunner. Run (ParentRunner. Java: 363)
The at org. Junit. Runner. JUnitCore. Run (JUnitCore. Java: 137)
At com. Intellij. Takeup. JUnit4IdeaTestRunner. StartRunnerWithArgs (JUnit4IdeaTestRunner. Java: 68)
At com. Intellij. Rt. Execution. Junit. IdeaTestRunner $Repeater. StartRunnerWithArgs (IdeaTestRunner. Java: 47)
At com. Intellij. Rt. Execution. Junit. JUnitStarter. PrepareStreamsAndStart (JUnitStarter. Java: 242)
At com. Intellij. Rt. Execution. Junit. JUnitStarter. Main (70) JUnitStarter. Java:
The Process finished with exit code 0
CodePudding user response:
May be caused by imgpath slashes, put all the need to use quotes around the string to replace the question markCodePudding user response: