943,150 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Marked Solved
  • Views: 820
  • JSP RSS
Nov 18th, 2009
-2

three JSF questions and (related to Oracle)

Expand Post »
The name of this question is “three JSF questions”
Hello and Thank you in advance for any assistance.


System info:

Netbeans,MySQL,glassfish

The Purpose of this post is:

have someone look at the excel file (subscribe_app_notes2)at :

http://cid-b5cb457363230793.skydrive...se.aspx/Public


The functionality of this code is:

I have the whole package I am creating (pseudo code) stated there along with 3 questions I am presently trying to figure out.

My question is:


One: I am using MySQL and the tutorial I am studying uses Oracle so I need to resolve the resource tag?

Two: My web.xml is different from the one presented in the tutorial. Could someone point out what needs to be added or changed to get it to work with my project?

Three: One of my classes (TopLinkSubscriberDAO.java) is using imports related to Oracle. I am exploring oracle to resolve this. Is anyone able to explain how to resolve errors in this class?

The errors related to this code are:


Code description:

JSP Syntax (Toggle Plain Text)
  1.  
Thanks again.
-ceyesumma

Note: If you are note willing to look at the exel file that is understandable. I just use it to present every single aspect of the project I am trying to build.
………………………………………………………………………………………………

Code description

JSP Syntax (Toggle Plain Text)
  1.  
Similar Threads
Reputation Points: 7
Solved Threads: 2
Posting Pro
ceyesuma is offline Offline
524 posts
since Aug 2007
Nov 18th, 2009
0

revised 3 JSF questions related to oracle also

The name of this question is revised “three JSF questions”
Hello and Thank you in advance for any assistance.


System info:

Netbeans,MySQL,glassfish
Studing tutorial at:
http://www.oracle.com/technology/pub...anu_jsfdb.html
note: hopefully this link is still good.


The Purpose of this post is:

to understand how to resolve with a class with links to oracle toplink DAO and if it is possible to use MySQL databade as apposed to an Oracle database.

The functionality of this code is:

add data to database with JSF

My question is:


One: I am using MySQL and the tutorial I am studying uses Oracle so I need to resolve the resource tag?

Code description: web.xml from the tutorial

JSP Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <!DOCTYPE web-app PUBLIC
  4. "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  5. "http://java.sun.com/dtd/web-app_2_3.dtd">
  6.  
  7. <web-app>
  8.  
  9. <context-param>
  10. <param-name>adminEmail</param-name>
  11. <param-value>admin@localhost</param-value>
  12. </context-param>
  13.  
  14. <context-param>
  15. <param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
  16. <param-value>jdbc/OracleDS</param-value>
  17. </context-param>
  18.  
  19. <context-param>
  20. <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  21. <param-value>client</param-value>
  22. </context-param>
  23.  
  24. <servlet>
  25. <servlet-name>FacesServlet</servlet-name>
  26. <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  27. <load-on-startup>1</load-on-startup>
  28. </servlet>
  29.  
  30. <servlet-mapping>
  31. <servlet-name>FacesServlet</servlet-name>
  32. <url-pattern>*.faces</url-pattern>
  33. </servlet-mapping>
  34. <resource-ref>
  35. <res-ref-name>jdbc/OracleDS</res-ref-name>
  36. <res-type>javax.sql.DataSource</res-type>
  37. <res-auth>Container</res-auth>
  38. </resource-ref>
  39.  
  40. <welcome-file-list>
  41. <welcome-file>index.jsp</welcome-file>
  42. </welcome-file-list>
  43.  
  44. </web-app>
Two: My web.xml is different from the one presented in the tutorial. Could someone point out what needs to be added or changed to get it to work with my project?

Code description: My present web.xml

JSP Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  3. <context-param>
  4. <param-name>com.sun.faces.verifyObjects</param-name>
  5. <param-value>false</param-value>
  6. </context-param>
  7. <context-param>
  8. <param-name>com.sun.faces.validateXml</param-name>
  9. <param-value>true</param-value>
  10. </context-param>
  11. <context-param>
  12. <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  13. <param-value>client</param-value>
  14. </context-param>
  15. <servlet>
  16. <servlet-name>Faces Servlet</servlet-name>
  17. <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  18. <load-on-startup>1</load-on-startup>
  19. </servlet>
  20. <servlet-mapping>
  21. <servlet-name>Faces Servlet</servlet-name>
  22. <url-pattern>/faces/*</url-pattern>
  23.   </servlet-mapping>
  24.   <session-config>
  25.   <session-timeout>
  26.   30
  27.   </session-timeout>
  28.   </session-config>
  29.   <welcome-file-list>
  30.   <welcome-file>subscribe/welcomeJSF.jsp</welcome-file>
  31.   </welcome-file-list>
  32.   </web-app>
  33.  

Three: One of my classes (TopLinkSubscriberDAO.java) is using imports related to Oracle. I am exploring oracle to resolve this. Is anyone able to explain how to resolve errors in this class?

Code description: TopLinkSubsriberDAO.java oracle imports

JSP Syntax (Toggle Plain Text)
  1. package jsfdb.model.dao;
  2.  
  3. import jsfdb.model.LoginInfo;
  4. import jsfdb.model.Subscriber;
  5. import jsfdb.model.ModelUtils;
  6. import jsfdb.model.err.IncorrectPasswordException;
  7. import jsfdb.model.err.LoginException;
  8. import jsfdb.model.err.ProfileException;
  9. import jsfdb.model.err.SubscribeException;
  10. import jsfdb.model.err.UnknownSubscriberException;
  11. import jsfdb.model.err.UnsubscribeException;
  12.  
  13. import oracle.toplink.expressions.ExpressionBuilder;
  14. import oracle.toplink.queryframework.ReadObjectQuery;
  15. import oracle.toplink.sessions.Session;
  16. import oracle.toplink.sessions.UnitOfWork;
  17. import oracle.toplink.threetier.ClientSession;
  18. import oracle.toplink.threetier.Server;
  19. import oracle.toplink.tools.sessionmanagement.SessionManager;


Code description: TopLinkSubscriberDAO.java

JSP Syntax (Toggle Plain Text)
  1. package jsfdb.model.dao;
  2.  
  3. import jsfdb.model.LoginInfo;
  4. import jsfdb.model.Subscriber;
  5. import jsfdb.model.ModelUtils;
  6. import jsfdb.model.err.IncorrectPasswordException;
  7. import jsfdb.model.err.LoginException;
  8. import jsfdb.model.err.ProfileException;
  9. import jsfdb.model.err.SubscribeException;
  10. import jsfdb.model.err.UnknownSubscriberException;
  11. import jsfdb.model.err.UnsubscribeException;
  12.  
  13. import oracle.toplink.expressions.ExpressionBuilder;
  14. import oracle.toplink.queryframework.ReadObjectQuery;
  15. import oracle.toplink.sessions.Session;
  16. import oracle.toplink.sessions.UnitOfWork;
  17. import oracle.toplink.threetier.ClientSession;
  18. import oracle.toplink.threetier.Server;
  19. import oracle.toplink.tools.sessionmanagement.SessionManager;
  20.  
  21. public class TopLinkSubscriberDAO implements SubscriberDAO {
  22. private Server serverSession;
  23.  
  24. public TopLinkSubscriberDAO() {
  25. SessionManager manager = SessionManager.getManager();
  26. String id = ModelUtils.getResource("TopLinkSession");
  27. ClassLoader loader = this.getClass().getClassLoader();
  28. serverSession = (Server) manager.getSession(id, loader);
  29. Runtime.getRuntime().addShutdownHook(new Thread() {
  30. public void run() {
  31. serverSession.logout();
  32. SessionManager.getManager().getSessions().remove(
  33. ModelUtils.getResource("TopLinkSession"));
  34. }
  35. });
  36. }
  37.  
  38. private ClientSession acquireClientSession() {
  39. return serverSession.acquireClientSession();
  40. }
  41.  
  42. private UnitOfWork acquireUnitOfWork() {
  43. return acquireClientSession().acquireUnitOfWork();
  44. }
  45.  
  46. private Subscriber read(Session session, String email) {
  47. ReadObjectQuery query
  48. = new ReadObjectQuery(Subscriber.class);
  49. ExpressionBuilder builder = new ExpressionBuilder();
  50. query.setSelectionCriteria(builder.get("email").equal(email));
  51. return (Subscriber) session.executeQuery(query);
  52. }
  53.  
  54. public Subscriber select(LoginInfo loginInfo)
  55. throws LoginException,
  56. UnknownSubscriberException,
  57. IncorrectPasswordException {
  58. Subscriber s = null;
  59. try {
  60. ClientSession session = acquireClientSession();
  61. s = read(session, loginInfo.getEmail());
  62. } catch (Exception x) {
  63. ModelUtils.log(x);
  64. throw new LoginException();
  65. }
  66. if (s == null)
  67. throw new UnknownSubscriberException();
  68. if (!s.getPassword().equals(loginInfo.getPassword()))
  69. throw new IncorrectPasswordException();
  70. return s;
  71. }
  72.  
  73. public void insert(Subscriber subscriber)
  74. throws SubscribeException {
  75. try {
  76. UnitOfWork uow = acquireUnitOfWork();
  77. Subscriber s = new Subscriber();
  78. ModelUtils.copy(subscriber, s);
  79. uow.registerObject(s);
  80. uow.commit();
  81. } catch (Exception x) {
  82. ModelUtils.log(x);
  83. throw new SubscribeException();
  84. } }
  85.  
  86. public void update(Subscriber subscriber)
  87. throws ProfileException {
  88. try {
  89. UnitOfWork uow = acquireUnitOfWork();
  90. Subscriber s = read(uow, subscriber.getEmail());
  91. ModelUtils.copy(subscriber, s);
  92. uow.commit();
  93. } catch (Exception x) {
  94. ModelUtils.log(x);
  95. throw new ProfileException();
  96. }
  97. }
  98.  
  99. public void delete(Subscriber subscriber)
  100. throws UnsubscribeException {
  101. try {
  102. UnitOfWork uow = acquireUnitOfWork();
  103. Subscriber s = read(uow, subscriber.getEmail());
  104. uow.deleteObject(s);
  105. uow.commit();
  106. } catch (Exception x) {
  107. ModelUtils.log(x);
  108. throw new UnsubscribeException();
  109. }
  110. }
  111.  
  112. }


The errors related to this code are:


Code description:

JSP Syntax (Toggle Plain Text)
  1.  
Thanks again.
-ceyesumma

Note: If you are note willing to look at the exel file that is understandable. I just use it to present every single aspect of the project I am trying to build.
………………………………………………………………………………………………

Code description

JSP Syntax (Toggle Plain Text)
  1.  
Reputation Points: 7
Solved Threads: 2
Posting Pro
ceyesuma is offline Offline
524 posts
since Aug 2007
Nov 20th, 2009
-1

solved

It seems the only option is to declare the JDBC\datasorce an use the standard jdbc api. Oracle will have to wait
thanks
Reputation Points: 7
Solved Threads: 2
Posting Pro
ceyesuma is offline Offline
524 posts
since Aug 2007
Nov 20th, 2009
-1

entitymanager

I guess the oracle program just generates code using the GUI.

It works fine with the entitymanger.
Reputation Points: 7
Solved Threads: 2
Posting Pro
ceyesuma is offline Offline
524 posts
since Aug 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: dynamic table in jsp
Next Thread in JSP Forum Timeline: Session Expire





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC