1 Reply Latest reply on Jan 26, 2007 3:25 PM by peterj

    how to make a jdbc connection to oracle db ?

    hussain.maricar

      my requirement is that my mbeans needs to do some database lookup. I am not using EJBS but i need to do some insert and db lookup using oracle db. I am new to jboss . how are the jdbc connections made and can i do all the db related stuff in my mbeans it self ? can someone help me really fast . my basic doubt is fundamental . i have worked with jdbc as standalone java applications . but dont know how to go about this in the world of jboss

        • 1. Re: how to make a jdbc connection to oracle db ?
          peterj

          The basic steps are to first define a *-ds.xml file for your database. Examples can be found at docs/examples/jca. Then in your application, you can look up the datasource using JNDI and from there get the JDBC connection:

          Context ctx = new InitialContext();
          DataSource ds = (DataSource)ctx.lookup("java:myDS");
          Connection c = ds.getConnection();

          When you are done, close the connection to release it back to the connection pool.