Results 1 to 4 of 4

Thread: Syntax for SQL query in JSP.

  1. #1
    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+"%'"

  2. #2
    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.

  3. #3
    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>
    
    />

  4. #4
    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.

Similar Threads

  1. SQL Server - Update Query Syntax Error
    By rmadler in forum Software Development
    Replies: 2
    Last Post: 02-02-2010, 05:10 AM
  2. Want to make query dependent on another query.
    By MACE in forum Software Development
    Replies: 4
    Last Post: 01-02-2010, 05:22 PM
  3. MySQL query in a query
    By Rail racer in forum Software Development
    Replies: 3
    Last Post: 21-07-2009, 07:06 PM
  4. Turn on MySQL query cache to speed up query performance
    By DMA2Superman in forum Software Development
    Replies: 3
    Last Post: 07-07-2009, 10:26 AM
  5. LDAP Search Query Syntax
    By etienne in forum Active Directory
    Replies: 1
    Last Post: 06-08-2008, 07:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,293,579.15202 seconds with 16 queries