在J2EE的config目录下default.propertities中
家上你的oracle数据库的配置
jdbc.drivers=oracle.jdbc.driver.OracleDriver
jdbc.datasources=jdbc/Cloudscape|jdbc:oracle:thin:@pcs3:1521:poland

解决方案 »

  1.   

    谢谢了哥们!
    我现在到是好象加上了在config\resources.property文件下.因为我在启动j2ee的时候看到了binding 我的datasource了
    J2EE server listen port: 1050
    Naming service started:1050
    Binding DataSource, name = jdbc/EstoreDB, url = jdbc:cloudscape:rmi:CloudscapeDB;create=true
    Binding DataSource, name = jdbc/DB1, url = jdbc:cloudscape:rmi:CloudscapeDB;create=true
    Binding DataSource, name = jdbc/Cloudscape, url = jdbc:cloudscape:rmi:CloudscapeDB;create=true
    Binding DataSource, name = jdbc/InventoryDB, url = jdbc:cloudscape:rmi:CloudscapeDB;create=true
    Binding DataSource, name = jdbc/DB2, url = jdbc:cloudscape:rmi:CloudscapeDB;create=true
    Binding DataSource, name = jdbc/Oracle, url = jdbc:oracle:thin:@10.1.1.217:1526:bkx;create=true
    Binding DataSource, name = jdbc/ora8, url = jdbc:oracle:thin:@callcenter:1521:ora8;create=true
    Binding DataSource, name = jdbc/XACloudscape, url = jdbc/XACloudscape__xa
    Binding DataSource, name = jdbc/XACloudscape__xa, dataSource = COM.cloudscape.core.RemoteXaDataSou
    rce@5e2ccd
    Starting JMS service ... Initialization complete - waiting for client requests
    您看应该没有问题了吧!现在我的程序编译通过了,但是用应用程序的客户端去调用时候发生莫名其妙的异常,说
    C:\j2sdkee1.3\com\zpw\ejb\JustSoSo>java SoSoClient
    Caught an exception.
    javax.naming.NameNotFoundException: jndiSoSo not found
            <<no stack trace available>>C:\j2sdkee1.3\com\zpw\ejb\JustSoSo>
    看来是我的jndi没有找到?!哥们能不能把您的code炫耀一下呢?!
    谢谢!my email : [email protected]
      

  2.   

    private String dbName = "java:comp/env/jdbc/Oracle "; 
      

  3.   

    哎呀根本就不是那么一回事了
    事情是多磨的:
    1)javax.naming.NameNotFoundException: jndiSoSo not found
      我从新编译就过了;
    2)如果用你的private String dbName = "java:comp/env/jdbc/Oracle "; 
      提示我javax.naming.NameNotFoundException: NamingException not found
    3)如果用private String dbName = "jdbc/Oracle "; 
      提示我javax.naming.NameNotFoundException: Oracle not found
    真是不知所以啊,哥们直说好吗.
      满眼都是眼泪啊!
      

  4.   

    what application server are you using?
    if jboss 
       dbName="java:/Oracle"
    else if weblogic
       i think dbName = "java:comp/env/jdbc/Oracle"
      

  5.   

    先告诉application server 是什么?什么版本?
      

  6.   

    我用的是j2sdkee1.3啊,我的眼泪都流干了
      

  7.   

    发布的时候看看你的应用下面是否已经将DATASOURCE JNDI NAME与你在程序中的REFERENCE NAME 关联起来 。
      

  8.   

    Application Server>=EJB Container
    Jboss2.4 3.0 is coming, wait for it.
    Weblogic6.1 You can get the crack file from net.
      

  9.   

    我现在到是能让程序找到数据库了,但是不能connect您看吧:  public String SoSo(String SoSo){
         String strTmp = "warning ,this varable is not initialize !";     
         try{
             initCtx = new InitialContext();
             System.out.println("initial is ok !!!!!!!!!!!!!!!!!!!!!"); 
             ds = (javax.sql.DataSource) initCtx.lookup("java:comp/env/oracleDB");
             System.out.println("connections is ok ??????");
             con =  ds.getConnection();//"jive","jive"
             System.out.println("connections is ok !!!!!!!!!!!!!!!!!!!!!");     
             String selectStatement = "select JUSTSOSO from EJBSoSo where JUSTSOSO = ? ";
             PreparedStatement prepStmt = con.prepareStatement(selectStatement);
             prepStmt.setString(1, "SoSo");
             ResultSet rs = prepStmt.executeQuery();
             while(rs.next()){
                strTmp=rs.getString(1);
             }
         }catch(javax.naming.NamingException ne){
            System.out.println(ne);
         }catch(SQLException sqle){
    System.out.println( sqle);
         }
         return strTmp;    
      } 以下是%J2EE_HOME%log下的system.log:
    ..........The EJBServer's daemon port is configured to: 1050
    c:\j2sdkee1.3\repository\zhangpiwang\applications\JustSoSo994321269361Server.jar
    Binding name:`java:comp/env/refJustSoSoBean`
    Binding name:`java:comp/env/oracleDB`
    Server waiting for invocations ...
    initial is ok !!!!!!!!!!!!!!!!!!!!!
    connections is ok ??????
    java.sql.SQLException: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=135290880)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
    ............j2ee里的Resource ref是system 和 admin的帐号和密码,我其它的密码帐号也试了,
    我不知道问题之所在!
    做个程序够难的,其实感觉这根本不是什么难题么,就是个流程配置的问题,那位高手指点一下!谢谢了!
      

  10.   

    在发布的时候,指定的 datasource resource ref的jndi name 的用户名和密码是指oracle
    的用户名和密码。
      

  11.   

    继续虚心求教::
    当然这个我明白的,我是指定的oracle的密码啊,比如jive,jive吧。我用其他的应用程序(直接调用jdbc)的可以了,(我所说的system和admin是oracle的系统帐号嘛)import java.io.*;
    import java.sql.*;
    import java.lang.*;public class AppToDBEjb{
      public static void main (String args[]){
        Connection DBConn=null;
        Statement DBStmt=null;
        String strTmp = null ; 
        ResultSet rs = null;
        try{
          //input parameter
          String DBUrl="jdbc:oracle:thin:@10.1.1.217:1529:ora9i";
          String DBUserName="jive";
          String DBPassword="jive";      boolean BooleanResult;
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          DBConn=DriverManager.getConnection(DBUrl,DBUserName,DBPassword);
          System.out.println("connections is ok !!!!!!!!!!!!!!!!!!!!!");     
          String selectStatement = "select *  from EJBSOSO where JUSTSOSO = 'SoSo' ";
          DBStmt = DBConn.createStatement();     
          //DBStmt.setString(1, "SoSo");
          rs = DBStmt.executeQuery(selectStatement);     
          System.out.println(rs);
          while(rs.next()){
             System.out.println("why");
              strTmp=rs.getString(1);
              System.out.println("result : "+ strTmp);          
          }
          /*
          prepStmt.close();
          DBConn.close();
          */
        }//end of the all try
        catch(SQLException e)
        {
            System.out.println(e);
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
      }
    }但是现在我在j2ee中就是不好使的:
    import java.rmi.RemoteException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.sql.*;
    import javax.sql.*;
    import javax.naming.*;public class SoSoEJB implements SessionBean {
        
      private javax.sql.DataSource ds;
      private java.sql.Connection con;
      private java.sql.PreparedStatement stmt;    
      private InitialContext initCtx;  public String SoSo(String SoSo){
         String strTmp = "warning ,this varable is not initialize !";     
         try{
             initCtx = new InitialContext();
             System.out.println("initial is ok !!!!!!!!!!!!!!!!!!!!!"); 
             ds = (javax.sql.DataSource) initCtx.lookup("java:comp/env/oracleDB");
             System.out.println("connections is ok ??????");
             con =  ds.getConnection();//"jive","jive"
             System.out.println("connections is ok !!!!!!!!!!!!!!!!!!!!!");     
             String selectStatement = "select JUSTSOSO from EJBSoSo where JUSTSOSO = ? ";
             PreparedStatement prepStmt = con.prepareStatement(selectStatement);
             prepStmt.setString(1, "SoSo");
             ResultSet rs = prepStmt.executeQuery();
             while(rs.next()){
                strTmp=rs.getString(1);
             }
         }catch(javax.naming.NamingException ne){
            System.out.println(ne);
         }catch(SQLException sqle){
    System.out.println( sqle);
         }
         return strTmp;    
      }  
      /**
       * the empty constructure of ConverterEJB
       */
      public SoSoEJB() {
      /**
       * the empty constructure of ConverterEJB
       */     
      };
      /**
       * the void method ejbCreate() initiate the initial status of the session bean;
       */
      public void ejbCreate() {};
      /**
       * the void method ejbRemove() destroy the session bean;
       */
      public void ejbRemove() {};
      /**
       * the void method ejbActivate() active the session bean 
       */
      public void ejbActivate() {};
      /**
       * the void method passivate the session bean ,it push the memory 
       * into the stack
       */
      public void ejbPassivate() {};
      /**
       * 
       */   
      public void setSessionContext(SessionContext sc){};
    }  哎呀哥们烦死我了,您要是做过,给个“痛快好”么?
      

  12.   

    继续虚心求教::
    当然这个我明白的,我是指定的oracle的密码啊,比如jive,jive吧。我用其他的应用程序(直接调用jdbc)的可以了,(我所说的system和admin是oracle的系统帐号嘛)import java.io.*;
    import java.sql.*;
    import java.lang.*;public class AppToDBEjb{
      public static void main (String args[]){
        Connection DBConn=null;
        Statement DBStmt=null;
        String strTmp = null ; 
        ResultSet rs = null;
        try{
          //input parameter
          String DBUrl="jdbc:oracle:thin:@10.1.1.217:1529:ora9i";
          String DBUserName="jive";
          String DBPassword="jive";      boolean BooleanResult;
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          DBConn=DriverManager.getConnection(DBUrl,DBUserName,DBPassword);
          System.out.println("connections is ok !!!!!!!!!!!!!!!!!!!!!");     
          String selectStatement = "select *  from EJBSOSO where JUSTSOSO = 'SoSo' ";
          DBStmt = DBConn.createStatement();     
          //DBStmt.setString(1, "SoSo");
          rs = DBStmt.executeQuery(selectStatement);     
          System.out.println(rs);
          while(rs.next()){
             System.out.println("why");
              strTmp=rs.getString(1);
              System.out.println("result : "+ strTmp);          
          }
          /*
          prepStmt.close();
          DBConn.close();
          */
        }//end of the all try
        catch(SQLException e)
        {
            System.out.println(e);
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
      }
    }但是现在我在j2ee中就是不好使的:
    import java.rmi.RemoteException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.sql.*;
    import javax.sql.*;
    import javax.naming.*;public class SoSoEJB implements SessionBean {
        
      private javax.sql.DataSource ds;
      private java.sql.Connection con;
      private java.sql.PreparedStatement stmt;    
      private InitialContext initCtx;  public String SoSo(String SoSo){
         String strTmp = "warning ,this varable is not initialize !";     
         try{
             initCtx = new InitialContext();
             System.out.println("initial is ok !!!!!!!!!!!!!!!!!!!!!"); 
             ds = (javax.sql.DataSource) initCtx.lookup("java:comp/env/oracleDB");
             System.out.println("connections is ok ??????");
             con =  ds.getConnection();//"jive","jive"
             System.out.println("connections is ok !!!!!!!!!!!!!!!!!!!!!");     
             String selectStatement = "select JUSTSOSO from EJBSoSo where JUSTSOSO = ? ";
             PreparedStatement prepStmt = con.prepareStatement(selectStatement);
             prepStmt.setString(1, "SoSo");
             ResultSet rs = prepStmt.executeQuery();
             while(rs.next()){
                strTmp=rs.getString(1);
             }
         }catch(javax.naming.NamingException ne){
            System.out.println(ne);
         }catch(SQLException sqle){
    System.out.println( sqle);
         }
         return strTmp;    
      }  
      /**
       * the empty constructure of ConverterEJB
       */
      public SoSoEJB() {
      /**
       * the empty constructure of ConverterEJB
       */     
      };
      /**
       * the void method ejbCreate() initiate the initial status of the session bean;
       */
      public void ejbCreate() {};
      /**
       * the void method ejbRemove() destroy the session bean;
       */
      public void ejbRemove() {};
      /**
       * the void method ejbActivate() active the session bean 
       */
      public void ejbActivate() {};
      /**
       * the void method passivate the session bean ,it push the memory 
       * into the stack
       */
      public void ejbPassivate() {};
      /**
       * 
       */   
      public void setSessionContext(SessionContext sc){};
    }  哎呀哥们烦死我了,您要是做过,给个“痛快好”么?
      

  13.   

    大侠,要是您明白,就说说真相吧,否则我就改其他的application server 了,不过我还是咬紧牙关先用sun的东西做出来,这样做出来会知道基础一点的东西,您说呢