2 Replies Latest reply: Dec 12, 2006 11:28 PM by 544615 RSS

    JDeveloper10g -> JSP and Database connectivity sample please

    544615
      Please someone send me a sample JSP page develped in JDeveloper10g.
      It should create a connection (like <database:dbOpen connId="conn1" user="scott" password="tiger" dataSourcee=??> )
      Is dataSource="jdbc:oracle:thin:@121.100.110.7:1521:ORCL" allowed.
        • 1. Re: JDeveloper10g -> JSP and Database connectivity sample please
          475314
          Here you are, sample JSP page that connects Oracle database and select.

          <%@ page import="java.sql.*" %>
          <HTML>
          <HEAD>
          <TITLE>Simple JSP/Oracle Query Example</TITLE>
          </HEAD>
          <BODY>
          <%
          Connection connection = null;
          try
          {
          Class.forName("oracle.jdbc.driver.OracleDriver");
          connection = DriverManager.getConnection("jdbc:oracle:thin:@121.100.110.7:1521:ORCL", "scott", "tiger");
          Statement statement = connection.createStatement();
          ResultSet resultSet = statement.executeQuery("SELECT ENAME FROM SCOTT.EMP");
          while(resultSet.next())
          out.println(resultSet.getString("ENAME") + "<BR/>");
          }
          catch(Exception exception)
          {
          out.println("Exception : " + exception.getMessage() + "<BR/>");
          }
          finally
          {
          if(connection != null)
          {
          try
          {
          connection.close();
          }
          catch (Exception ignored)
          {
          ; // ignore
          }
          }
          }
          %>
          </BODY>
          </HTML>
          • 2. Re: JDeveloper10g -> JSP and Database connectivity sample please
            544615
            It worked!!.
            But I want to use the components of "OJSP JSP".
            <p>&lt;%@ taglib uri=&quot;http://java.sun.com/jstl/sql&quot; prefix=&quot;sql&quot;%&gt;<br>
            &lt;%@ taglib uri=&quot;http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/sqltaglib.tld&quot;
            prefix=&quot;database&quot;%&gt;<br>
            &lt;%@ page contentType=&quot;text/html;charset=windows-1252&quot;%&gt;<br>
            &lt;html&gt;<br>
            &lt;head&gt;<br>
            &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;&gt;<br>
            &lt;title&gt;untitled&lt;/title&gt;<br>
            &lt;/head&gt;<br>
            &lt;body&gt;<br>
            &lt;database:dbOpen connId=&quot;scott_conn&quot; password=&quot;tiger&quot; user=&quot;scott&quot; dataSource=&quot;jdbc:oracle:thin:@localhost:1521:orcl&quot;&gt;<br>
            &lt;database:dbQuery connId=&quot;scott_conn&quot; queryId=&quot;emp_qry&quot;/&gt;<br>
            ???????<br>
            ?????<br>
            &lt;/database:dbOpen&gt;<br>
            &lt;/body&gt;<br>
            &lt;/html&gt;</p>