简体   繁体   中英

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>

When I run this in the web browser I am receiving an error.

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 : 

The HTML File HTML File

remove the quotes from insert into stock_tbl values ('?','?') . the 2 ? are being interpreted as values not placeholders.

here's an example http://www.codejava.net/java-ee/jstl/jstl-sql-tag-param

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM