Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-06-2009
Member
 
Join Date: May 2008
Posts: 29
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+"%'"
Reply With Quote
  #2  
Old 04-06-2009
Member
 
Join Date: May 2008
Posts: 31
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.
Reply With Quote
  #3  
Old 04-06-2009
Member
 
Join Date: Jan 2009
Posts: 40
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>

/>
Reply With Quote
  #4  
Old 04-06-2009
Member
 
Join Date: May 2008
Posts: 29
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Syntax for SQL query in JSP."
Thread Thread Starter Forum Replies Last Post
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
MySQL query in a query Rail racer Software Development 3 21-07-2009 07:06 PM
Turn on MySQL query cache to speed up query performance DMA2Superman Software Development 3 07-07-2009 10:26 AM
LDAP Search Query Syntax etienne Active Directory 1 06-08-2008 07:47 PM


All times are GMT +5.5. The time now is 10:56 AM.