最好做成ejb的resource reference

解决方案 »

  1.   

    1  Specify the database name. 
       private String dbName =
          "java:comp/env/jdbc/SavingsAccountDB";
     2  Obtain the DataSource associated with the logical name. 
       InitialContext ic = new InitialContext();
       DataSource ds = (DataSource) ic.lookup(dbName);
     3  Get the Connection from the DataSource. 
       Connection con =  ds.getConnection();
      

  2.   

    1  Specify the database name. 
       private String dbName =
          "java:comp/env/jdbc/SavingsAccountDB";
     2  Obtain the DataSource associated with the logical name. 
       InitialContext ic = new InitialContext();
       DataSource ds = (DataSource) ic.lookup(dbName);
     3  Get the Connection from the DataSource. 
       Connection con =  ds.getConnection();
      

  3.   

    eyeieye(魔之眼) :
      在Deploytool中做这个resouce ref 吗?
      是不是要将oracle的驱动放在ejb中的lib里面呢?
      我已经作了一个但是连接不上啊