1 Reply Latest reply on Mar 26, 2004 9:51 AM by jae77

    JDBC Connection

    nitro

      Hi,

      I'm new to nukes (and to jboss and the rest of the j2ee - stuff). I just wrote my first small block and module. Its great, thx for the framework!

      But for a first approach I want to connect to the database with JDBC (later then with ejbs, but this can wait). How do I get the datasource to connect to the database. It would be great, if somebody could post some code or give some tips.

      thx
      Martin

        • 1. Re: JDBC Connection
          jae77

          the datasource is already "connected" when it deploys, you just need to ask for a connection.

          InitalContext context = new InitialContext();
          Datasource ds = (DataSource) context.lookup("java:/NukesDS");
          Connection conn = ds.getConnection();
          


          of course, you'll need to handle any exceptions those methods may throw, etc, but that should be enough to get you started.