|
| |||||||||
| Tags: jsp, query, sql, syntax |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| Syntax for SQL query in JSP.
Hi, I am new with JSP so i want to know how to use SQL syntax in jsp? I want to connect with the sql database & fetch output. this is my query Code: "SELECT employee FROM email WHERE employee like '%"+newUserID+"%'" |
|
#2
| ||||
| ||||
| Re: Syntax for SQL query in JSP.
I hope you have put exception in your code. Please use exception handling feature provided by JVM so you will come to know the exact problem with your code. |
|
#3
| |||
| |||
| Re: Syntax for SQL query in JSP.
Syntax of JSP Declaratives is: <%! //java codes %> JSP Declaratives begins with <%! and ends with %> try this code. Code: <sql:setDataSource
var="variable"
driver="oracle.jdbc.driver.OracleDriver"
user="a"
password="b"
<sql:query var="jack">
SELECT * FROM mytable
</sql:query>
<%-- Get the column names for the header of the table --%>
<c:forEach var="columnName" items="${jack.columnNames}">
<th><c:out value="${columnName}"/></th>
</c:forEach>
<%-- Get the value of each column while iterating over rows --%>
<c:forEach var="row" items="${jack.rows}">
<tr>
<c:forEach var="column" items="${row}">
<td><c:out value="${column.value}"/></td>
</c:forEach>
</tr>
</c:forEach>
/> |
|
#4
| ||||
| ||||
| Re: Syntax for SQL query in JSP.
You must always put your business logic in JAVA classes & call these classes from jsp. Even if you put your SQL statements in JSP it will be hidden from the client & the client will only see the html code. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Syntax for SQL query in JSP." | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Query in SQL v/s Query in Oracle | Satchel | Software Development | 4 | 29-12-2010 07:19 AM |
| SQL Server - Update Query Syntax Error | rmadler | Software Development | 2 | 02-02-2010 05:10 AM |
| Want to make query dependent on another query. | MACE | Software Development | 4 | 01-02-2010 05:22 PM |
| Turn on MySQL query cache to speed up query performance | DMA2Superman | Software Development | 3 | 07-07-2009 11:26 AM |
| LDAP Search Query Syntax | Giles | Active Directory | 1 | 06-08-2008 08:47 PM |