1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Rep Power

    does does lookup("java:/comp/env") mean?

    i have this code..
    i know it is used to get a connection to postgres database eventually but wat does the "java:/comp/env" refer to?

    and what do i have to do if i want to change from postgres to mysql database?

    Context envContext  = (Context)initialContext.lookup("java:/comp/env");
    datasource = (DataSource)envContext.lookup("jdbc/postgres");
    any help is appreciated..
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Rep Power
    The "java:/com/env/" is supposed to be an entry in your JNDI provider.

    Application Servers have a JNDI service provider that houses things like your Database Connection pool and other resources (EJB's, LDAP, ...). This adds a level of abstraction to your code so that the database connection information is independant to you your code.

    Here is a link that may explain it better that I can...

    To switch to MySQL from another db you have to change your app servers config by adding a new entry or replacing an existing entry to the list of JNDI service providers or the datasource config. This is dependant on you app server as to how you would go about doing this. I would check your app server's documentation.

    You then would change the String argument in the .lookup() method to the new entry you made.

    Hope this helps.

IMN logo majestic logo threadwatch logo seochat tools logo