govinda wrote:
How do I connect to a datasource thru code without context "java:comp/env"

Context envContext  = (Context)initContext.lookup("java:comp/env");

I just want to connect to DB like this

DataSource ds = (DataSource)initContext.lookup("jdbc/LiferayPool");

Is it possible, if so where do I specify java jndi context ("java:comp/env")
outside the code?
If I have not misunderstood you last question and although I am not a G developer I hope no one minds I jump in an try to help out.

In Liferay there are several ways to set up a database connection but you probably want to use Geronimo:s connection pool and sins Liferay 5.2.2 it is ones again possible to set up the application server connection pools JNDI name by specify the following line in your portal-ext.properties file.

###application server connection pools JNDI name
jdbc.default.jndi.name=jdbc/LiferayPool

I am not sure the following is required but I also have this in the end of the web.xml file.
   <!-- Geronimo usage -->
      <resource-ref>
              <res-ref-name>jdbc/LiferayPool</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>

Hope this helps.
For more information about this take a look at http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Database%20Configuration


regards
   peter petersson

Thanks

Reply via email to