SQLJ+JSP
hello sir
i am using CMP EJB with SQLJ but my problem is when i use this code
i am using this code in jsp page for login purpose
to check login and password in login table
#sql public context DefaultContext;
SafeCon sa=new SafeCon();
ctxx =sa.init();
#sql [ctxx] {
select distinct * from login where acc0=:uname and acc1=:upassword
then it will give the illegal charcter error on # line
and malformed error so can u pls tell me how to solve it
i am using jdeveloper
thanks alot
I will answer myself, so people that has the same problem can see this:
Make a jsp page (callingprogram.jsp) that calls the following file: EXECUTESQLJ.jsp (the file name could be whatever):
-- CALLINGPROGRAM.JSP --
<%@ page contentType="text/html;charset=windows-1252"%>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>
jsp to execute a pl/sql (sqlj)
</TITLE>
</HEAD>
<BODY>
Ejecutar un PL/SQL es cuestion de colocar el codigo en JAVA respectivo:
<FORM method="post" action="executesqlj.jsp" onreset="alert('LA FORMA ES REINICIADA')">
Presione el boton --><INPUT type="submit" value="Ejecutar">
<BR>
Para Reiniciar valores presione ---> <INPUT type="reset" value="Reiniciar"></TD>
</FORM>
</BODY>
</HTML>
Then, the file EXECUTESQLJ.JSP should has a look like this:
<%@ page language="sqlj"
contentType="text/html;charset=windows-1252"
import="oracle.jbo.*,
java.sql.SQLException,sqlj.runtime.ref.DefaultContext,
sqlj.runtime.ConnectionContext,java.sql.Connection,
oracle.sqlj.runtime.Oracle,mypackage1.java2" %>
<-- mypackage1.java2 is the wrapper sqlj that the JDEV has created with the option GENERATE JAVA... -->
<HTML>
<HEAD>
<TITLE>
Executing sqlj....
</TITLE>
</HEAD>
<BODY>
<% // Codificacion de Java para llamar el procedimiento.
Oracle.connect(new java2().getClass(), "connect.properties");
<% /* remember creating the file connect.properties in your package directory
The file has to be like this:
sqlj.url=jdbc:oracle:thin:@servidor:1521:ORCL
# User name and password here (edit to use different user/password)
sqlj.user=scott
sqlj.password=tiger
*/ %>
java2 execsql = new java2();
execsql.testjava();
%>
<jsp:forward page="callingprogram.jsp" />
</BODY>
</HTML>
Hope this could help the jdevs guys!.
Similar Messages
-
SQLJ JSP and SERVLETS which Environment?
Hello,
I am attempting to run the samples on Chapter 5 of the
following documents with partial success.
http://technet.oracle.com/docs/products/oracle8i/doc_library/817_
doc/java.817/a83726/oraext2.htm
http://download-west.oracle.com/otndoc/oracle9i/901_doc/java.901/
a90208/oraext.htm#1015820
1. Do I need the Apache+Jserv environment to run SQLJ and JSP?
2. What do I need to do run SQLJ on oc4j if possible?
3. I dont know how to load(?) and/or run this .sqljsp file.
<%@ page language="sqlj"
import="sqlj.runtime.ref.DefaultContext,oracle.sqlj.runtime.Oracl
e" %>
<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:oracle:oci8:@", "scott",
"tiger");
#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();
%>
I named above file as test2.sqljsp then I tried these procedures:
a) $ ojspc test2.sqljsp --these created all the files
b) $ loadjava -u -v scott/tiger _test2.class -resolve
this generated:
initialization complete
loading : _test2
creating : _test2
resolver :
resolving: _test2
errors : _test2
ORA-29521: referenced name test2$_jsp_StaticText could not
be found
ORA-29521: referenced name test2SJProfileKeys could not be
found loadjava: 2 errors
c) listed the directory and both these files are there but it
cannot resolve or find it?
d) I recall reading something about publishjsp command but I have
to establish a session shell with OSE? this part is very
confusing and am not sure what to do here.
e) not sure if i need to publish the loaded class (create a
procedure? so it can be known to the rest of plsql?)
A step by step procedure is very much appreciated. fyi.. I
have Oracle 8.1.7, + oc4j, I can run sqlj from command line
and class files generated I can run. I can also run JSP and
servlets on the oc4j accessing the database. It is this SQLJ
that throws me off balance. If you include Jdeveloper steps
ro run SQLJ thats also welcome.
Thanks in advance for kind responses posted.In many Model-View-Controller web applications implemented using J2EE, servlets are as controllers to direct the flow between the model and view. While servlets can output HTML code directly, it is much better to use JSPs for the most part. JSPs contain HTML and possibly Java scriptlets. The J2EE container will typically compile JSPs into servlets. While you could use a JSP as a controller, there are drawbacks to that approach. To minimize the amount of Java code in your JSPs, you can either use the tags provided by the JSP spec or use tag libraries written by someone else or yourself. See the JSTL for one such example.
Also see:
http://wiki.java.net/bin/preview/Javapedia/MVC
http://wiki.java.net/bin/view/Javapedia/JavaServerPages -
I have small test JSP to use SQLJ. Using JDeveloper works fine with embedded OC4J. But when deployed to TomCat 5 fails with the below error. I copied translator.jar and runtime12.jar from C:\oracle\ora92\sqlj\lib to C:\Tomcat\common\lib but still fails. Any ideas greatly appretiated!
Error:
org.apache.jasper.JasperException: /sqlj1.jsp(7,0) Page directive: invalid language attribute
My page directive that caused error:
page language="sqlj"
import="sqlj.runtime.ref.DefaultContext,oracle.sqlj.runtime.Oracle"behzadku, i never worked with Tomcat 3.0 (have you considered updating?), but i have worked with Tomcat 3.2.3 and i'm currently using 4.0.1. Reloading always worked fine for JavaServer Pages. As dhchau mentioned, what could happen is that your browser cache the pages. Try your browsers reload button and make sure that you copy your new pages to the right destination.
It's a different thing for classes and libs. You have to configure your context container to make Tomcat reload them automatically.
HTH, Markus -
Using SQLJ from JSP in JDeveloper
Hello,
Has anyone succeeded in creating a JSP file by using SQLJ in JDeveloper 3.1 (Build 681)?
In the whitepaper http://technet.oracle.com/docs/tech/java/servlets/jsp/whitepapers/jsp-oow99-paper.pdf
it is stated that you can create an SQLJ-JSP by giving the JSP file the .sqljsp extension. This results in an "Fatal error: compiler internal error." in JDeveloper.
In the same whitepaper, it is stated that you can also use the following JSP page directive to create an SQLJ-JSP page:
"<%@ page language="sqlj" %>"
This results in an "Error: (16) illegal character." error in JDeveloper at the mere sight of "#sql".
Any help would be appreciated.
HelgiHi,
there is something wrong with the code.
I will update you when it is fixed
(1352536) -
Can i use SQLJ in a normal java project?
I created a normal Java Project and used SQLJ in it.But when i exported the jar file,there was a error:
JAR creation failed. See details for additional information.
class file(s) on classpath not found or not accessible /DBTableApp/com/ezkj/demo/sqlj/Ctx.java
Can i use SQLJ in a normal java project?
If i can,what can i do?hi
good
go through this link
http://www.service-architecture.com/application-servers/articles/when_to_use_sqlj_with_java_application_servers.html
http://www.service-architecture.com/application-servers/articles/sqlj_data_conversion.html
Payroll Cluster table "top Important" Urgent
http://www.javaolympus.com/J2SE/Database/SQLJ/SQLJ.jsp
thanks
mrutyun -
Hello All,
Have just started with <i>Open SQL/SQLJ</i> and have tried the 1st program on <i>Relational Persistence</i> on link: http://help.sap.com/saphelp_nw2004s/helpdata/en/b8/092492099b7c44b266c3128624076e/frameset.htm
I have read that SQLJ is not so compatible with JDBC. So wanted to know that when SQLJ is translated, does it talk to the databse using JDBC internally?
Example: SQLJ -> converted to JDBC -> interaction with DB.
Just by learning about the db schema from the Catalog, how does SQLJ commands be understood by the database?
Awaiting Reply.
Thanks & Warm Regards,
Rituhi
good
go through this link, which ll give you detail idea about the SQLJ,
http://www.javaolympus.com/J2SE/Database/SQLJ/SQLJ.jsp
thanks
mrutyun^ -
How to use classes in AppModule?
How can I use custom classes (eg sqlj generated classes) in ApplicationModule?
I have some classes doing lots of db work, and I'd like to have a handle for it in my ApplicationModule.
Thx: Tib
nullAdding a class to your project is the same
regardless of project type.
You have code which calls this new class.
i.e. I assume you have methods in your AppModule which evenetually call this new class.
Add the class (Java, SQLJ, JSP, XSQL, etc) to
your project.
Add this class (if not done automatically) to
this project's deployment profile's list of files to include for deployment.
Then deploy and the class is available in the new deployment target.
I hope this is not too generic,
and can help you with your deployment.
-John
null -
Can only use Stratus in a non-commerical project?
I wanted to make a game which eventually I would make commerical (ads, sponsorship, micro-transactions, selling, etc). But after reading this article it seems I can't use it for commerical use... Is this true, or perhaps did I read it wrong? I mean in the description for Stratus I does say to make multiplayer games and I would like to make one and make money at the same time...
hi
good
go through this link
http://www.service-architecture.com/application-servers/articles/when_to_use_sqlj_with_java_application_servers.html
http://www.service-architecture.com/application-servers/articles/sqlj_data_conversion.html
Payroll Cluster table "top Important" Urgent
http://www.javaolympus.com/J2SE/Database/SQLJ/SQLJ.jsp
thanks
mrutyun -
I am running small SQLJ in a JSP to get the hang of it.
I am running on 920, and have downloaded the new runtime classes for 920 and tested per the instructions.
Using JDev 903, here is the private method for running a query ( It is from an article I found by Julie Basu at Oracle; I have played around with the empno/emp_no variable to convert it to an int):
<%! private String runQuery(String emp_no) throws java.sql.SQLException {
DefaultContext dctx =null;
String ename = null; double sal = 0.0; String hireDate=null;
StringBuffer sb = new StringBuffer();
//int emp_no = Integer.parseInt(emp_no);
try {
dctx =Oracle.getConnection("jdbc:oracle:oci8:@olap","scott","tiger");
#sql [dctx] { SELECT ename, sal, TO_CHAR(hiredate,'DD-MON-YYYY')
INTO :ename,:sal,:hireDate
FROM scott.emp WHERE empno=:emp_no
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();
%>
I keep getting the following error:
java.lang.NoSuchFieldError: oracle.jdbc.oci8.OCIEnv.envCharSetId
int oracle.jdbc.oci8.OCIEnv.get_env_handle()
native code
long oracle.jdbc.oci8.OCIEnv.getEnvHandle()
OCIEnv.java:70
oracle.jdbc.dbaccess.DBConversion oracle.jdbc.oci8.OCIDBAccess.logon(java.lang.String, java.lang.String, java.lang.String, java.util.Properties)
OCIDBAccess.java:390
void oracle.jdbc.driver.OracleConnection.<init>(oracle.jdbc.dbaccess.DBAccess, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Properties)
OracleConnection.java:361
java.sql.Connection oracle.jdbc.driver.OracleDriver.getConnectionInstance(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Properties)
OracleDriver.java:485
java.sql.Connection oracle.jdbc.driver.OracleDriver.connect(java.lang.String, java.util.Properties)
OracleDriver.java:337
java.sql.Connection java.sql.DriverManager.getConnection(java.lang.String, java.util.Properties, java.lang.ClassLoader)
DriverManager.java:517
java.sql.Connection java.sql.DriverManager.getConnection(java.lang.String, java.lang.String, java.lang.String)
DriverManager.java:177
void sqlj.runtime.ref.ConnectionContextImpl.<init>(sqlj.runtime.ref.ProfileGroup, java.lang.String, java.lang.String, java.lang.String, boolean)
ConnectionContextImpl.java:346
void sqlj.runtime.ref.DefaultContext.<init>(java.lang.String, java.lang.String, java.lang.String, boolean)
DefaultContext.java:172
sqlj.runtime.ref.DefaultContext oracle.sqlj.runtime.Oracle.getConnection(java.lang.String, java.lang.String, java.lang.String, boolean)
Oracle.java:580
sqlj.runtime.ref.DefaultContext oracle.sqlj.runtime.Oracle.getConnection(java.lang.String, java.lang.String, java.lang.String)
Oracle.java:609
java.lang.String _SQLJ.runQuery(java.lang.String)
[SQLJ.jsp]
SQLJ.jsp:42
void SQLJ.jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
[SQLJ.jsp]
SQLJ.jsp:20
void com.orionserver[Oracle9iAS (9.0.3.0.0) Containers for J2EE].http.OrionHttpJspPage.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
OrionHttpJspPage.java:56
[SRC:/SQLJ.jsp]
void oracle.jsp.runtimev2.JspPageTable.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
JspPageTable.java:317
void oracle.jsp.runtimev2.JspServlet.internalService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
JspServlet.java:465
void oracle.jsp.runtimev2.JspServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
JspServlet.java:379
void javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
HttpServlet.java:853
void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
ServletRequestDispatcher.java:721
void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse)
ServletRequestDispatcher.java:306
boolean com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.ApplicationServerThread, com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletRequest, com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletResponse, java.io.InputStream, java.io.OutputStream, boolean)
HttpRequestHandler.java:767
void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(java.lang.Thread)
HttpRequestHandler.java:259
void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run()
HttpRequestHandler.java:106
void EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run()
PooledExecutor.java:803
void java.lang.Thread.run()
Thread.java:484
When I run it using just JDBC with the thin Driver, I have no problems.
What could be the issue?
Thanks,
Scott RappoportFail to make OCI connection Using JDeveloper
-
Using SQLJ in JSP files ... ?
Hi,
has anyone used oracle 8.1.5 SQLJ with JSP pages? In partucilar, with Apache Tomcat 3.0?
Help much appreciated, direct mails ([email protected]) preferred!
Cheers, all - keep up the good work!
nullHi,
Yes, OJSP inside JDeveloper cannot currently handle the language="sqlj" extension. A workaround is to name your file Foo.sqljsp.
Before running the JSP on a webserver you will need to map the sqljsp extension to the class oracle.jsp.JspServlet, just as for OJSP setup, and then you can hit the page directly:
http://<host>:<port>/SQLJQuery.sqljsp
Let us know if you have problems..
- Julie
null -
Does anyone know how to develop JSP using SQLJ? This chapter is not availabe in the developer's guide. And which one is a better solution, JSP + BC4J or SQLJ?
I would stick with the JDK 1.1.8 in JDeveloper 3.0. SQLJ and JDBC do not yet support JDK 1.2 (they will in Oracle 8.1.6 and JDeveloper 3.1... not sure about OAS 4.0.9, but I would suspect so).
Laura -
I want to embed SQLJ in a javaserver page. But JDeveloper doesn't understand that this is a SQLJ file unless I change the extension of the file from .jsp into .sqlj
I heard from an extension .sqljsp, but if I use that, Jdeveloper crashes.
Does anybody know a solution for this?
nullJDeveloper doesn't automatically translate any SQLJ code embedded in a JSP - you'd have to translate your SQLJ code outside of JDeveloper.
The best solution is to put your SQLJ code in a web bean.
Thanks
Blaise -
Can I use SQLJ instead of JSP ?
Hi:
Can I use SQLJ instead of JSP to work with Oracle Mobile / Wireless ?
ThanksYou can use any language that can output XML - There is a Tag Glossary for the Oracle9iAS Wireless XML on http://studio.oraclemobile.com .
Regards,
Kalle
[email protected]
Hi:
Can I use SQLJ instead of JSP to work with Oracle Mobile / Wireless ?
Thanks -
Hello,
I have generated a sqlj wrapper class for a package, and now I want to execute a method that calls the pl/sql procedure inside the .sqlj program thru JSP. How do I do that?
I tried <%=methodgenerated() %>, but doesn't work.
It's a stored procedure not a function. I looked for an example and I just found the runQuery() example everywhere, but didn't find an example about running a procedure from JSP.
I also did the steps about language="sqlj" and import.... but I need an example about doing this action.
Could you please help me with this?
Thanks in advance.I will answer myself, so people that has the same problem can see this:
Make a jsp page (callingprogram.jsp) that calls the following file: EXECUTESQLJ.jsp (the file name could be whatever):
-- CALLINGPROGRAM.JSP --
<%@ page contentType="text/html;charset=windows-1252"%>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>
jsp to execute a pl/sql (sqlj)
</TITLE>
</HEAD>
<BODY>
Ejecutar un PL/SQL es cuestion de colocar el codigo en JAVA respectivo:
<FORM method="post" action="executesqlj.jsp" onreset="alert('LA FORMA ES REINICIADA')">
Presione el boton --><INPUT type="submit" value="Ejecutar">
<BR>
Para Reiniciar valores presione ---> <INPUT type="reset" value="Reiniciar"></TD>
</FORM>
</BODY>
</HTML>
Then, the file EXECUTESQLJ.JSP should has a look like this:
<%@ page language="sqlj"
contentType="text/html;charset=windows-1252"
import="oracle.jbo.*,
java.sql.SQLException,sqlj.runtime.ref.DefaultContext,
sqlj.runtime.ConnectionContext,java.sql.Connection,
oracle.sqlj.runtime.Oracle,mypackage1.java2" %>
<-- mypackage1.java2 is the wrapper sqlj that the JDEV has created with the option GENERATE JAVA... -->
<HTML>
<HEAD>
<TITLE>
Executing sqlj....
</TITLE>
</HEAD>
<BODY>
<% // Codificacion de Java para llamar el procedimiento.
Oracle.connect(new java2().getClass(), "connect.properties");
<% /* remember creating the file connect.properties in your package directory
The file has to be like this:
sqlj.url=jdbc:oracle:thin:@servidor:1521:ORCL
# User name and password here (edit to use different user/password)
sqlj.user=scott
sqlj.password=tiger
*/ %>
java2 execsql = new java2();
execsql.testjava();
%>
<jsp:forward page="callingprogram.jsp" />
</BODY>
</HTML>
Hope this could help the jdevs guys!. -
Viewing Images from Database using JSP/ SQLJ
Dear Friends,
I could manage to write an image into a BLOB Field in the Oracle
Database. I could even manage to read that image from the
database but i am doing it by reading the BLOB data and writing
it into a file with 'gif' or 'jpeg' extension.
I would like to know how to read the BLOB data dynamically in
cache and display it on the JSP page in the browser without
creating a file on the disk.
Thanking you,
SarwottamThanks for replying,
Can you please elaborate on your suggestions ?
If possible can you provide a sample code that would help me understand better?
Thanks again.
Sarwottam
Maybe you are looking for
-
Using a single remote app to control multiple Apple TVs
Can you use the remote application which is loaded on my IPad 2 to control multiple ATVs independently? If so, how is this done.
-
Albums folder in iPhoto Library folder missing
The Albums folder in iPhoto Library folder missing. This means when I try to sync photos to my iPod (video) in iTunes, none of my photo albums show up (though I can seclect a specific folder useing year, month day, etc.). It also mens that I must nav
-
Stapler - A python utility for manipulating PDF docs based on pypdf
Link to github: http://github.com/hellerbarde/stapler/tree/master * Dependencies * Stapler depends only on the packages python and python-pypdf, both of which can be found in the archlinux repositories. * History * Stapler is a pure python replacemen
-
No attribute appear in new custom VSA RADIUS
Hi, I use Cisco Secure version 3.2 on windows 2000 I just had a new custom VSA Radius with the utility CSUtil.exe Fist i create the file myvsa.ini, this is for a SONET optical Nortel equipement, here it is: [User Defined Vendor] Name=OM3000 IETF Code
-
Im trying to populate through odbc certain fields on the form, [ex. patient_id, firstname, last name, address, etc] which must change when primary/unique field [hence patient_id] is updated. Relationship is dictated by default from db and is picked u