0 Replies Latest reply on Mar 7, 2002 9:09 PM by luckystar_007

    ?jsp lookup datasource

    luckystar_007

      Hi;
      All,I have encountered the problem;
      I use JBoss-2.4.3_Tomcat-3.2.3,
      I put Oracle Driver in /lib/ext,

      I edit the /conf/tomcat/jboss.properties like this:
      ...
      jboss.xa.xidclass=oracle.jdbc.xa.OracleXid
      ...


      I edit the /conf/tomcat/jboss.jcml like this:
      ...


      org.hsqldb.jdbcDriver,oracle.jdbc.driver.OracleDriver

      ...


      OracleDS_1
      org.jboss.pool.jdbc.xa.XAPoolDataSource

      jdbc:oracle:thin:@192.168.210.69:1521:EAPORA
      1200000
      eap
      10
      eap
      false
      false
      false
      true
      120000
      1800000
      false
      false
      1.0
      0



      OracleDS_2
      org.jboss.pool.jdbc.xa.XAPoolDataSource

      jdbc:oracle:thin:@192.168.210.88:1521:unieap
      1200000
      eap
      10
      eap
      false
      false
      false
      true
      120000
      1800000
      false
      false
      1.0
      0


      ...
      my jsp code is like this:
      <%
      UserTransaction ut=null;
      try{

      Properties _props = new Properties();
      _props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      _props.setProperty(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
      _props.setProperty(Context.PROVIDER_URL, "localhost:1099");

      InitialContext ctx = new InitialContext(_props);


      ut=(UserTransaction)ctx.lookup("UserTransaction");


      ut.begin();

      //Context jndiContext = new InitialContext();

      out.println("Before lookup OracleDS_1");
      DataSource ds1 =(DataSource)ctx.lookup("java:/OracleDS_1");
      out.println("After lookup OracleDS_1");
      Connection conn_1=ds1.getConnection();

      out.println("Before lookup OracleDS_2");
      DataSource ds2 =(DataSource)ctx.lookup("java:/OracleDS_2");
      out.println("After lookup OracleDS_2");
      Connection conn_2=ds2.getConnection();

      Statement stat_1=conn_1.createStatement();
      Statement stat_2=conn_2.createStatement();

      String strSQL_1="update GAOTABLE set age = 18";
      String strSQL_2="update JIANTABLE set age = 19";

      stat_1.execute(strSQL_1);
      stat_2.execute(strSQL_2);

      conn_1.close();
      conn_2.close();
      ut.commit();


      if ( (conn_1!=null) && (conn_2!=null)){
      out.print("yes, we succeed");
      }else{
      out.println("no, we failed");
      }
      }catch(Exception e){
      if (ut!=null){
      try{
      ut.rollback();
      }catch(Exception ex){
      ex.printStackTrace();
      out.print("Exception!");
      }
      }else{
      e.printStackTrace();
      out.print("Exception");
      }
      }
      %>


      the trouble is ; I failed on lookup datasource, my boss feel angry now,Any body help me!