Anurag Gupta

Ranch Hand
+ Follow
since Dec 13, 2001
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anurag Gupta

If you look at the definition of HttpServlet:

and its super class, the GenericServlet

Since GenericServlet implements Serializable, then whats the need for the HttpServlet to implement Serializable again?
Am I missing something here !!!
13 years ago
My Application Architecture is like:

The DAO is present for loose coupling between Business and DataBase. The various DAO Implementations, which we could plug in:
  • CMP Entity Beans for DAO Implementation (using either of Remote/Local interfaces) <- This being the concern area.
  • JDBC for DAO Implementation

  • - There are no Web Module in the application

    1) Is it possible to look up a Entity Local Home from the POJO Business Utility, which is also deployed as a dependent jar file? If Yes, how?
    (It is possible to do so from an EJB or a Web Cointainer, by the use of ejb-local-ref in the Container deployment descriptor).

    2) In a Clustered enviornment, if two threads (on different cluster) are accessing the same Entity data row for updation, is there a possibility of compromising Data Integrity (Assuming Isolation Level is set as Cursor Stability i.e level 2).
    I am facing a similar issue.
    It looks like, the java:comp/xxx is available only from within the container.
    From outside the container (in a stand alone java client), you would need to look up the exact JNDI Name.

    Going a step further :
    InFact, a pojo which is deployed on the appserver along with some EJBs (as a dependent jar file) is also unable to use java:comp/xxx to look up any resource.
    Bottom Line: Only EJBS and Servlets can use java:comp/xxx.

    Anyone has a better idea/alternative ?
    I am trying to get a database connection from a Java client application, which is outside the WAS container. i.e. a standalone java class.
    A working DataSource is already configured in WAS 6, with connection pool [Security is NOT enabled].

    A deployed servlet with the following code works fine:

    However if the java client outside the container, trys to get a connection from the same Connection pool, there is a error. (The difference is in getting the InitialContext only)

    This code, throws a ClassCastException , because the l_obj returned is not of type DataSource, but of Resource type.

    1) Does that mean, Webspher does not allow its own DataBase connection pool to be used outside the container ?
    2) If it is allowed, then how do accomplish this, in a standlaone java client?

    15 years ago
    Whether to perform commit/rollback programatically for persistance code in a Bean Managed Persistance for an Entity Bean?
  • Entity Bean - BMP: We need to provide logic for persistance to a Database.
  • Entity Bean - HAS to have Container Managed Transaction (atleast for the Remote Business Methods).

  • Following is a pseudo code. What should be done at the question marks?
    I am using Sun's Reference Implementation of J2EE with a Simple StatelessSession Bean (e.g. HelloBean) deployed in it.
    I have a client which needs to invoke the business method exposed in this bean. However this client is OUTSIDE the Ejb Container, in a different JVM.
    Generally if the client application client is also deployed within the EJB CONTAINER, the std code would be as follows :

    But the Client NEEDS to be outside the EJB Container, hence would have the JNDI lookup Modifications as follows :

    The PROBLEM is for SUN's Reference Implementation WHAT are the TWO Properties :
  • There may be instances, where you would need :
  • DataBase Specific Calls e.g Getting Database date/timestamp
  • Vendor Specific Calls

  • In such a case you could store the Query Statements in either:
  • A table of the database.
  • In Memory Location of the application, which loads on start e.g. a HashTable which could be initialized on startup using static {} of the class.

  • 1) If you are using a jdbc connection object in an AUTOCOMMIT=TRUE mode, then u dont need to issue the COMMIT explictly. However if the jdbc connection object is in an AUTOCOMMIT=FALSE Mode, then you need to explicitly commit the connection in order for the change to take place.
    java.sql.Connection setAutoCommit(boolean autoCommit)
    2) This condition is perfectly valid. The application design should take care of such situations.
    You could use a select for update query, which would lock the record, so that none can modify it.(However this approach could have a repercussion of a Record becoming Locked, if the user does not proceed after the select.)
    As Wayne rightfully said, it depends upon the Datbase and Driver implementation mainly.
    You could look for some additional info here.
    I would recommend jdbc drivers from Data Direct (Formerly known as Merant) : (1) Merant SequeLink Server (2) Connect for JDBC
    On Windows following file contains port numbers for well-known services defined by IANA :
    If your DataBase is Designed correctly (Indexes etc), and if you are using Connection Pooling of a Good Driver, then Running PL/SQL(Business Logic) using JDBC would not be slow.
    17 years ago
    In your Query you could use an equivalent of Decode in Oracle, if there is any in DB2.
    You would require JSQLConnect.jar to be present in your Classpath.
    Alternatively, copy this file in the folder JAVA_HOME/jre/lib/ext/
    The ClassName is com.jnetdirect.jsql.JSQLDataSource.