JSTL - 如何将值传递给 SQL 语句
JSTL - How can I pass values to SQL statement
<sql:setDataSource var="snapshot" driver="org.apache.derby.jdbc.ClientDriver"
url="jdbc:derby://localhost:1527/sample"
user="app" password="app"/>
<sql:update dataSource="${snapshot}" var="result">
insert into stock_tbl values ('?','?')
<sql:param value="${symb}" />
<sql:param value="${nm}" />
</sql:update>
当我 运行 在 Web 浏览器中执行此操作时,我收到错误消息。
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException:
insert into stock_tbl values ('?','?')
: UNKNOWN MESSAGE, id 07009 :
root cause
java.sql.SQLException: UNKNOWN MESSAGE, id 07009 :
root cause
org.apache.derby.client.am.SqlException: UNKNOWN MESSAGE, id 07009 :
HTML 文件
HTML File
删除 insert into stock_tbl values ('?','?')
中的引号。 2 ?
被解释为值而不是占位符。
这是一个例子
http://www.codejava.net/java-ee/jstl/jstl-sql-tag-param
<sql:setDataSource var="snapshot" driver="org.apache.derby.jdbc.ClientDriver"
url="jdbc:derby://localhost:1527/sample"
user="app" password="app"/>
<sql:update dataSource="${snapshot}" var="result">
insert into stock_tbl values ('?','?')
<sql:param value="${symb}" />
<sql:param value="${nm}" />
</sql:update>
当我 运行 在 Web 浏览器中执行此操作时,我收到错误消息。
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException:
insert into stock_tbl values ('?','?')
: UNKNOWN MESSAGE, id 07009 :
root cause
java.sql.SQLException: UNKNOWN MESSAGE, id 07009 :
root cause
org.apache.derby.client.am.SqlException: UNKNOWN MESSAGE, id 07009 :
HTML 文件 HTML File
删除 insert into stock_tbl values ('?','?')
中的引号。 2 ?
被解释为值而不是占位符。
这是一个例子 http://www.codejava.net/java-ee/jstl/jstl-sql-tag-param