1 Reply Latest reply on Apr 10, 2006 1:02 PM by carbonch

    Scheduler and JNDI

    msqrt84

      Hi!

      How can I get connection to DataSource from class derived from

      org.jboss.varia.scheduler.Schedulable

      using JNDI?

      Where is alternative for web.xml and jboss-web.xml?

      Thank you!

        • 1. Re: Scheduler and JNDI
          carbonch

          Are you looking for this piece of code?

          // get data base connection
          Context ctx = new InitialContext();
          DataSource ds = (DataSource) ctx.lookup("java:/MyDS");
          conn = ds.getConnection();
          
          // get data base driver
          Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
          
          // Execute the select
          pstmtSelect = conn.prepareStatement("SELECT * FROM MyTable");
          ResultSet rs = pstmtSelect.executeQuery();
          


          Regards,
          Reto