java.lang.ClassCastException


I get the above error in the following code. (RUNTIME ERROR).


Type casting to OracleConnection is what is suggested in Oracle JDBC
reference manual.

Any idea. Please!

-Krishna





import java.util.*;

import oracle.sql.*;
import oracle.jdbc.driver.*;

import javax.sql.DataSource;
import javax.naming.InitialContext;



import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

import etips.type.ItemDetail;
/**
 * @stereotype SessionBean
 */
public class ItemListBean
        implements SessionBean, SessionSynchronization

{

        private  SessionContext sessionContext = null;
        transient OracleConnection connection;
        transient DataSource dataSource;
        transient InitialContext ictx;

--- Some code here


        public void afterBegin()
                throws javax.ejb.EJBException, RemoteException
        {
          try {
                   connection = (OracleConnection) dataSource.getConnection();   
(RUNTIME
ERROR OCCURS ON THIS LINE)
               connection.setAutoCommit(false);
          }
          catch (Exception e) {
                 e.printStackTrace();
               throw new RemoteException("OrderItem: Cant get Connection");
         }
        }
        public void beforeCompletion()
                throws javax.ejb.EJBException, RemoteException
        {
        }
        public void afterCompletion(boolean flag)
                throws javax.ejb.EJBException, RemoteException
        {
          try {
               if (flag)
                    connection.commit();
               else
                    connection.rollback();
               connection.close();
          }
          catch (Exception e) {}
        }


        private OracleConnection getConnection() throws RemoteException{
                OracleConnection connection = null;
                try {
                        connection = (OracleConnection) dataSource.getConnection();
                }catch (Exception ex) {
                        throw new RemoteException();
                }
                return connection;
        }
}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to