2 Replies Latest reply on Dec 21, 1999 6:44 AM by 3004

    Error using SQLJ in JSP[

    3004
      I have read Whitepaper: "Database Access from JavaServer Pages" and try to run the following example source under "JDeveloper 3.0" and "JavaServer (TM) Web Development Kit 1.0.1" but fail.

      Error under "Jdeveloper 3.0" :
      Invalid attribute value, sqlj, for language.

      Error under "JavaServer (TM) Web Development Kit 1.0.1" :
      HTTP 500 - Internal server error

      For Jdeveloper 3.0, I have included the SQLJ Runtime under my project.
      For JavaServer (TM) Web Development Kit 1.0.1, I have set the CLASSPATH to include the SQLJ Runtime.

      Source Code :
      ***** Begin *****
      <%@ page language="sqlj" import="sqlj.runtime.ref.DefaultContext,oracle.sqlj.runtime.Oracle" %>
      <HTML>
      <HEAD> <TITLE> The SQLJQuery JSP </TITLE> </HEAD>
      <BODY BGCOLOR="white">
      <% String empno = request.getParameter("empno");
      if (empno != null) { %>
      <H3> Employee # <%=empno %> Details: </H3>
      <%= runQuery(empno) %>
      <HR><BR>
      <% } %>
      <B>Enter an employee number:</B>
      <FORM METHOD="get">
      <INPUT TYPE="text" NAME="empno" SIZE=10>
      <INPUT TYPE="submit" VALUE="Ask Oracle");
      </FORM>
      </BODY>
      </HTML>
      <%! private String runQuery(String empno) throws java.sql.SQLException {
      DefaultContext dctx = null;
      String ename = null; double sal = 0.0; String hireDate = null;
      StringBuffer sb = new StringBuffer();
      try {
      dctx = Oracle.getConnection("jdbc http://technet.oracle.com:89/ubb/redface.gifracle:thin:@hkg-wsn-3387:1521 http://technet.oracle.com:89/ubb/redface.gifra8i", "scott", "scotttiger");
      #sql [dctx] { SELECT ename, sal, TO_CHAR(hiredate, 'DD-MON-YYYY')
      INTO :ename, :sal, :hireDate
      FROM scott.emp WHERE UPPER(empno) = UPPER(:empno)
      };
      sb.append("<BLOCKQUOTE><BIG><B><PRE>\n");
      sb.append("Name : " + ename + "\n");
      sb.append("Salary : " + sal + "\n");
      sb.append("Date hired : " + hireDate);
      sb.append("</PRE></B></BIG></BLOCKQUOTE>");
      } catch (java.sql.SQLException e) {
      sb.append("<P> SQL error: <PRE> " + e + " </PRE> </P>\n");
      } finally {
      if (dctx!= null) dctx.close();
      }
      return sb.toString();
      }
      %>
      ***** End *****

      Can anyone help ?

      Rgds,
      Edward


      null