Who can explain how EJB connect to Oracle9i DB with DataSource?

I have taken 4 days into this problem. I am developing EJB with J2EE1.3 and Oracle9i DB, I can connect to DB in code with DriverManager. But I want to use DataSource to connect to DB. I failed, I can not get new way to resolve it when I after try to connect with javax.sql.DataSource, oracle.jdbc.pool.OracleDataSource and oracle.jdbc.pool.OracleConnectionPoolDataSource.
I have got different Exceptions when I coding different ways:
one is:
Caught an exception.
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: U
nable to connect to database. com.sun.enterprise.resource.JdbcDataSource; nested
exception is:
javax.ejb.EJBException: Unable to connect to database. com.sun.enterpris
e.resource.JdbcDataSource
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: Unable to
connect to database. com.sun.enterprise.resource.JdbcDataSource; nested excepti
on is:
javax.ejb.EJBException: Unable to connect to database. com.sun.enterpris
e.resource.JdbcDataSource
javax.ejb.EJBException: Unable to connect to database. com.sun.enterprise.resour
ce.JdbcDataSource
<<no stack trace available>>
the Other is:
Caught an exception.
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: U
nable to connect to database. makeConnection:Io Exception: Connection refused(DESCRIP
TION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)
))); nested exception is:
javax.ejb.EJBException: Unable to connect to database. makeConnection:Io
Exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_
STACK=(ERROR=(CODE=12505)(EMFI=4))))
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: Unable to
connect to database. makeConnection:Io Exception: Connection refused(DESCRIPTION=(TM
P=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))); nes
ted exception is:
javax.ejb.EJBException: Unable to connect to database. makeConnection:Io
Exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_
STACK=(ERROR=(CODE=12505)(EMFI=4))))
javax.ejb.EJBException: Unable to connect to database. makeConnection:Io Exception: C
onnection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(E
RROR=(CODE=12505)(EMFI=4))))
<<no stack trace available>>
My codes related are:
private void makeConnection() throws NamingException, SQLException {
try{
InitialContext ic = new InitialContext();
OracleConnectionPoolDataSource ocpds = (OracleConnectionPoolDataSource) ic.lookup(dbName);
PooledConnection pc = ocpds.getPooledConnection();
con = pc.getConnection();
}catch(SQLException ex){
throw new SQLException("makeConnection:" + ex.getMessage());
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
con = DriverManager.getConnection(
"jdbc:oracle:thin:@172.28.200.43:1521:shcd",
"lijun", "xiaotian"); */
public void setEntityContext(EntityContext context) {
this.context = context;
try {
makeConnection();
} catch (Exception ex) {
throw new EJBException("Unable to connect to database. " +
ex.getMessage());
I believe I set JNDI and config EJB right, because I can run it with Cloudscape DB all right.
who can tell me where is my WRONG, or tell me how to connect to Oracle9i DB?

Hi Jhlijun,
I am facing the same problem at the moment. However, I am not using a pooled connection. The following is my code. I am trying to connect a stateless session bean to an Oracle 9i database with result being fed back to a jsp page.
package Test;
import javax.naming.*;
import java.sql.*;
import java.util.*;
import javax.ejb.*;
import javax.sql.DataSource;
import javax.sql.*;
public class TestSessionEJBbean extends java.lang.Object implements javax.ejb.SessionBean
String q="Select NAMETITLE,NAMEFIRST,NAMELAST from People where PeopleRSN<100";
     protected boolean create() throws java.lang.Exception
return true;
public TestSessionEJBbean()
{   // EJB constructors don't have a server context.
private void unhandledEvent( String listenerName, String methodName, java.lang.Object event )
// method for interface javax.ejb.SessionBean
public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException
// To Do
// method for interface javax.ejb.SessionBean
public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException
// To Do
// method for interface javax.ejb.SessionBean
public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException
// To Do
// method for interface javax.ejb.SessionBean
public void setSessionContext( javax.ejb.SessionContext parm0 ) throws javax.ejb.EJBException, java.rmi.RemoteException
this._sessionContext = parm0;          // generated helper code
// To Do
* Test Method
public String Test() throws javax.ejb.EJBException
return "Hi! I am the SessionEjbBean.";
* Session Context of this EJB.
* Set in 'setSessionContext()' before any 'ejbCreate()' is executed.
private javax.ejb.SessionContext _sessionContext;
* ejbCreate Method
public void ejbCreate() throws javax.ejb.EJBException, javax.ejb.CreateException
try {
create(); // This 'create()' is used for internal initialization.
catch( java.lang.Exception __e) {
System.err.println( __e.toString() + " " + __e.getMessage() );
// TODO: implement
* getDBConnection Method
     public sun.jdbc.rowset.CachedRowSet getDBConnection() throws javax.ejb.EJBException
     String testPrint = "Starting...";//Only to check output
     Connection conn;
     sun.jdbc.rowset.CachedRowSet crset=null;
     try {
          testPrint += "before new InitialContext()....";//Only to check output
          InitialContext ic = new InitialContext();
          DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/coquit");
          testPrint += "before ds.getConnection()....";//Only to check output
          conn = ds.getConnection("coquit","coquit");          
               testPrint += "before conn.createStatement()....";
               Statement stmt=conn.createStatement();
               testPrint += "before stmt.executeQuery(....)";
               ResultSet rset = stmt.executeQuery(q);
               testPrint += "before new sun.jdbc.rowset.CachedRowSet()";     
               crset = new sun.jdbc.rowset.CachedRowSet();
               testPrint += "before crset.populate(rset)";
               crset.populate(rset);
               rset.close();
               stmt.close();
               conn.close();
     } catch (NamingException ne) {
     System.out.println("TestSessionEJBbean::getDBConnection Naming Exception " + ne);
     }catch (Exception e){
     System.out.println(testPrint+"...TestSessionEJBbean::getDBConnectionException" + e);
     System.out.println("\n\n");
     e.printStackTrace();
     return crset;

Similar Messages

  • Topic: Who can explain how EJB connect to Oracle9i DB with DataSource?

    I have taken 4 days into this problem. I am developing EJB with
    J2EE1.3 and Oracle9i DB, I can connect to DB in code with
    DriverManager. But I want to use DataSource to connect to DB. I
    failed, I can not get new way to resolve it when I after try to
    connect with javax.sql.DataSource,
    oracle.jdbc.pool.OracleDataSource and
    oracle.jdbc.pool.OracleConnectionPoolDataSource.
    I have got different Exceptions when I coding different ways:
    one is:
    Caught an exception.
    java.rmi.ServerException: RemoteException occurred in server
    thread; nested exception is:
    java.rmi.RemoteException: nested exception is:
    javax.ejb.EJBException: Unable to connect to database.
    com.sun.enterprise.resource.JdbcDataSource; nested
    exception is:
    javax.ejb.EJBException: Unable to connect to database.
    com.sun.enterprise.resource.JdbcDataSource
    java.rmi.RemoteException: nested exception is:
    javax.ejb.EJBException: Unable to
    connect to database. com.sun.enterprise.resource.JdbcDataSource;
    nested exception is:
    javax.ejb.EJBException: Unable to connect to database.
    com.sun.enterprise.resource.JdbcDataSource
    javax.ejb.EJBException: Unable to connect to database.
    com.sun.enterprise.resource.JdbcDataSource
    <<no stack trace available>>
    the Other is:
    Caught an exception.
    java.rmi.ServerException: RemoteException occurred in server
    thread; nested exception is:
    java.rmi.RemoteException: nested exception is:
    javax.ejb.EJBException: Unable to connect to database.
    makeConnection:Io Exception: Connection refused(DESCRIPTION=
    (TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=
    (CODE=12505)(EMFI=4)
    ))); nested exception is:
    javax.ejb.EJBException: Unable to connect to database.
    makeConnection:Io
    Exception: Connection refused(DESCRIPTION=(TMP=)
    (VSNNUM=150999297)(ERR=12505)(ERROR_
    STACK=(ERROR=(CODE=12505)(EMFI=4))))
    java.rmi.RemoteException: nested exception is:
    javax.ejb.EJBException: Unable to
    connect to database. makeConnection:Io Exception: Connection
    refused(DESCRIPTION=(TM
    P=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)
    (EMFI=4)))); nested exception is:
    javax.ejb.EJBException: Unable to connect to database.
    makeConnection:Io
    Exception: Connection refused(DESCRIPTION=(TMP=)
    (VSNNUM=150999297)(ERR=12505)(ERROR_
    STACK=(ERROR=(CODE=12505)(EMFI=4))))
    javax.ejb.EJBException: Unable to connect to database.
    makeConnection:Io Exception: C
    onnection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)
    (ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
    <<no stack trace available>>
    My codes related are:
    private void makeConnection() throws NamingException,
    SQLException {
    try{
    InitialContext ic = new InitialContext();
    OracleConnectionPoolDataSource ocpds =
    (OracleConnectionPoolDataSource) ic.lookup(dbName);
    PooledConnection pc = ocpds.getPooledConnection();
    con = pc.getConnection();
    }catch(SQLException ex){
    throw new SQLException("makeConnection:" + ex.getMessage());
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    con = DriverManager.getConnection(
    "jdbc:oracle:thin:@172.28.200.43:1521:shcd",
    "lijun", "xiaotian"); */
    public void setEntityContext(EntityContext context) {
    this.context = context;
    try {
    makeConnection();
    } catch (Exception ex) {
    throw new EJBException("Unable to connect to database. " +
    ex.getMessage());
    I believe I set JNDI and config EJB right, because I can run it
    with Cloudscape DB all right.
    who can tell me where is my WRONG, or tell me how to connect to
    Oracle9i DB?

    Hi,
    on small thing to check (or perhaps do):
    Make sure that you are using the JDBC drivers from the Oracle9i
    DB client e.g. copy the classes12.jar from the ORACLE_HOME of
    the database client into OC4J_HOME lib.
    Also, one thing that might help is to define an explict Oracle
    datasource e.g.
    - Set class to value of Oracle DataSource class
    - Use only the location logical name
    - Returns Oracle implementation of java.sql.Connection
    <data-source
    class="oracle.jdbc.pool.OracleDataSource"
    name="jdbc/oracle/PooledDS"
    location="jdbc/oracle/PooledDS"
    username="scott"
    password="tiger"
    url="jdbc:oracle:thin:@<host>:<port>:<SID>"
    />
    Andy

  • Who can explain the message server string in the OSS connection ?

    Who can explain the message server string in the OSS connection ?  
    For example:
    MSG SERVER FIELD IS:
    /H/128.168.0.28/S/sapdp99/H/194.39.131.34/S/sapdp99/H/oss001
    What is the mean to each field in the string?
    What does the first "/H" mean?
    What does the second "/H" mean?
    What does the third "/H" mean?
    What does the first "/S" mean?
    What does the second "/S" mean?
    What does "/oss001" mean?
    Thanks .

    Hi,
    when you define  techinacal settings in tcode OSS1
    Transaction OSS1 -> Parameter -> Technical Settings -> Change -> Save. The SAPOSS destination is only automatically updated when you save.
    /H indicate server
    /S indicate Service
    check following SAP note
    Note 33135 - Guidelines for OSS1
    regards,
    kaushal

  • I just started using fire fox and I cant figure out how to add a new folder to my bookmarks. Can anybody explain how in detail (I'm bad with computers so I need real detail) Please and thank you. :)

    I just started using fire fox and I can't figure out how to add a new folder to my bookmarks.
    Can anybody explain how in detail (I'm bad with computers so I need real detail)
    Please and thank you. :)

    If you use extensions (Tools > Add-ons > Extensions) like <i>Adblock Plus</i> or <i>NoScript</i> or <i>Flash Block</i> that can block content then make sure that such extensions aren't blocking content.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    You can use one of these to start Firefox in <u>Safe mode</u>:
    *On Windows, hold down the Shift key while starting Firefox with a double-click on the Firefox desktop shortcut
    *On Mac, hold down the Options key while starting Firefox
    *Help > Restart with Add-ons Disabled
    If it works in Firefox Safe-mode then disable all extensions (Tools > Add-ons > Extensions) and then try to find which is causing it by enabling one extension at a time until the problem reappears.
    Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")
    See also:
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Someone who can say how to get Adpbe flash player version 11.2.202.197 to work together with Lion on mac mini. Support from Apple can obviously not help the problem and do not care if it works

    Someone who can say how to get Adpbe flash player version 11.2.202.197 to work together with Lion on mac mini. Support from Apple can obviously not help the problem and do not care if it works

    Adobe flash player version 11.2.202.197 is for Windows Vista / Windows 7 / Vista 64 / Windows 7 64
    Adobe Flash Player version 11.1.102.55 is the current version for Snow Leopard and Lion.
    Adobe - Install Adobe Flash Player

  • Who can explain inner class to me?

    //InheritInner.java
    //Inheriting an inner class
    class WithInner
         class Inner{
              Inner()
              {System.out.println("Inner class");
         WithInner()
         {System.out.println("WithInner");}
    public class InheritInner extends WithInner.Inner
         //!InheritInner(){}//Won't compile
         InheritInner(WithInner wi)
              wi.super();
         public static void main(String[] args)
              WithInner wi=new WithInner();
              InheritInner ii=new InheritInner(wi);
    Who can explain this subclass constructor to me?
    I appreciate your help!

    Here's the class that in 'Thinking in Java'. For some reason, yours is completely different.
    //: InheritInner.java
    // Inheriting an inner class
    class WithInner {
      class Inner {}
    public class InheritInner
        extends WithInner.Inner {
      //! InheritInner() {} // Won't compile
      InheritInner(WithInner wi) {
        wi.super();
      public static void main(String[] args) {
        WithInner wi = new WithInner();
        InheritInner ii = new InheritInner(wi);

  • Hi guys, can you please explain how to perform automatic system scan with CleanApp - it looks like it wants me to manually chose files to delete and I just want an automatic scan (like cleanmymac does)

    Hi guys, can you please explain how to perform automatic system scan with CleanApp - it looks like it wants me to manually chose files to delete and I just want an automatic scan (like cleanmymac does)

    Slowness...First Try using Disk Utility to do a Disk Repair, as shown in this link, while booted up on your install disk.
      You could have some directory corruption. Let us know what errors Disk Utility reports and if DU was able to repair them. Disk Utility's Disk Repair is not perfect and may not find or repair all directory issues. A stronger utility may be required to finish the job.
      After that Repair Permissions. No need to report Permissions errors....we all get them.
    Here's Freeing up Disk Space.
    DALE

  • How to connect MS-sql server with SAP BW

    hi all,
    i want the connection procedure to how to connect MS-sql server with SAP BW.so that i can extract the data from ms sql server and can create cubes using that data.please help me in this issue.

    Hi Vamshi,
    Go through this DOC it explains u how to connect to other data bases like SQL...
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/58f4db47-0501-0010-a2bf-ff01b150fdff]
    this is a thread related to connect the SQL server..
    [DB Connect MS SQL Server;
    Regards,
    NR
    Assign points if helpful...

  • How to connect a USB-6008 with lookout6.0?

    hi >>>
    I am a student in electrical and computer department, i want to ask about
    How to connect a USB-6008 with lookout6.0 if thats possible?Could you
    provide some help?
    Regards
    Manal

    Hi Manal there is a way to do this, DAQ or DAQmx drivers have an OPC server, you can find the detailed information in the next link
    http://digital.ni.com/public.nsf/websearch/13BBC10CCC1FECBA8625720B00823140?OpenDocument
    Best Regards
    Benjamin C
    Senior Systems Engineer // CLA // CLED // CTD

  • TS1986 how to connect usb optical mouse with scroll to mac

    hey its manish hea
    please can i get to know how to connect usb optical mouse with scroll so tat it can be used for AUTOCAD 2011
    i connected the mouse but its not working
    please suggest

    Welcome to the Forum!
    Well, there is no big deal about USB mouse, it's plug and play.If your mouse doesn't work at all, then its broken, or it's not compatible with mac. Test it in a PC.

  • How to connect my macbook air with thunderbolt to tv via hdmi?

    How to connect my macbook air with thunderbolt to tv via hdmi?

    With this adapter. You will also need an HDMI cable.
    The Thunderbolt port doubles as a mini DisplayPort on the MBA.

  • How to connect 2 iPod classics with bluetooth

    I am trying to sync photos between 2 iPod classics, iPad4 and iphone 5 with blue tooth. The only devices that are seeing each other is the iPhone and iPad but still hasn't' synced the photos. Why re the apple devices not able to see each other?

    Havilah Farm wrote:
    Why re the apple devices not able to see each other?
    Because that's the way Apple have designed it. They have used a particular Bluetooth protocol that is designed to allow audio to be transmitted to Bluetooth headphones or Bluetooth speakers (for example) and some peer-to-peer gaming between the devices, but not the transfer of files.
    To transfer photos, Sync them via your iTunes programme. If you took the photos on the device, transfer them to your computer first and then Sync them with the other devices. For photos that were not taken on the device, they presumably were Synced from your computer originally, so simply Sync them to your other devices from the computer.
    By the way, your subject question: "how to connect two iPod Classics with Bluetooth"...
    You cannot. The Classic does not have Bluetooth.

  • The new ios7 is horrible how can i downgrade? my messages keeps freezing im frustrated im very close to going ANDROID any one can help how do i get in touch with apple directly?

    the new ios7 is horrible how can i downgrade? my messages keeps freezing im frustrated im very close to going ANDROID any one can help how do i get in touch with apple directly?

    gorxxx83 wrote:
    the new ios7 is horrible how can i downgrade? my messages keeps freezing im frustrated im very close to going ANDROID any one can help how do i get in touch with apple directly?
    Downgrading is not supported.
    Here are some basic troubloeshooting tips:
    - Quit the App by opening multi-tasking bar, and swiping the App upward to make it disappear.  (For iOS 6, holding down the icon for the App for about 3-5 seconds, and then tap the red circle with the white minus sign.)
    - Relaunch the App and try again.
      - Restart the device. http://support.apple.com/kb/ht1430
    - Reset the device. (Same article as above.)
    - Reset All Settings (Settings > General > Reset > Reset All Settings)
    - Restore from backup. http://support.apple.com/kb/ht1766 (If you don't have a backup, make one now, then skip to the next step.)
    - Restore as new device. http://support.apple.com/kb/HT4137  For this step, do not re-download ANYTHING, and do not sign into your Apple ID.
    - Test the issue after each step.  If the last one does not resolve the issue, it is likely a hardware problem.
    If you want to contact Apple directly, call 1-800-MYAPPLE (1-800-692-7753), or go to getsupport.apple.com. 
    Don't waste your time asking for a downgrade of the iOS.  That's not an option.

  • Who can i make a set-reset flip-flop with labview interacting with for cycle outputs

    Who can i make a set-reset flip-flop with labview interacting with for cycle outputs

    Are you wanting a VI that emulates a RS filp flop, or do you have a question about using an actual one?
    You can make a RS flip flop by knowing the 4 states:
    R=0, S=0, Q=no change
    R=0, S=1, Q=1
    R=1, S=0, Q=0
    R=1, S=1, Q=?(invalid condition)
    I have attached a RS flip flop VI in LV version 6.0
    dhuff
    Attachments:
    RS_Flip_Flop.vi ‏34 KB

  • Is there a simple example, I can see how to connect to a db using Flash 8 and actionscript? (not with components)

    I have been looking all over for a simple "hello world"
    example, on how to connect to a database, and pass a param, and
    return a dataset. I would like one that does not use components.
    (Actionscript only). That uses ColdFusion 7.x and Flash 8. Can
    anyone point me to one?

    Thanks Craig, I saw that example, but it was meant for Flash
    MX, and according to the Flash 8 documentation, the NetServices is
    now deprecated. Anyway, I posted my question on another site and
    some supplied me with a simple example. Here is the url if anyone
    is interested...
    sample

Maybe you are looking for

  • Jabber and Desk Phone

    Hello guys, I've configured CUCM and IM&P v9.1 and jabber client 9.2(1), the chat works fine and also the Cisco Unified Client Services Framework Device can make and receive calls but if I try to select the desk phone for calls it just keeps trying t

  • Mac Keyboard Functions Don't Work

    I have just discovered that the Mac keyboard has a very useful feature: press and hold a key and all the options for that character show in a little pop-up window, i.e., accents, tilde's, etc. This works in all my other programs (Word, Excel, Pages,

  • HT4623 I can't see my mail, what should I do?

    I can not see my emails. I already updated my phone up to date...could you please suggest me what to do?

  • Mac Mini i5/2.5GHz/4GB RAM MD387xx/A

    Hello, I have this Mac Mini i5/2.5GHz/4GB RAM MD387xx/A, and I just want to know if I can put those RAM (16GB) in it. https://www.digitec.ch/de/s1/product/kingston-hyperx-impact-2x-8gb-ddr3-1600-sod imm-204-arbeitsspeicher-3229730?tagIds=76 Thanks

  • ITunes Video Compared to DVD on MBP?

    I want Scrubs season 5 on DVD. But season 4 comes out in October so who knows when season 5 will be out. It's available on iTunes but I am concerned about the quality. If I download the season, will it compare to DVD quality on my MBP? I found this w