Posts

Showing posts with the label Glassfish

Glassfish JNDI settings

Image
Recently we had the need to add some configurable settings (such as user credentials) in a Java EE 7 application running on Glassfish 4.0. An example method to read the values might look like this:     private String getUserProperty(String property) {         String result = "";         Properties properties;         try {             InitialContext context = new InitialContext();             properties = (Properties) context.lookup("jndi/userinfo");             result = properties.getProperty(property);             context.close();         } catch (NamingException e) {         }         return result;     } Setting the values via the Glassfish console is achieved via Resources -> JNDI -...

Glassfish Informix JDBC

Image
I recently had a need to get an Informix database connection going on Glassfish .  This is documented but what I found was not quite enough to get me going. I was using the JDBC driver from IBM .  After the driver is installed, there are six jar files in the lib directory.  Given that Informix is one of our primary databases, we use this driver with a variety of Java-based development tools.  Typically this involves making the ifxjdbc.jar file available on the CLASSPATH and you're good to go. In order to create an Informix JDBC Connection Pool in Glassfish,  I found that I needed to put both the ifxjdbc.jar and the ifxjdbcx.jar files in Glassfish lib directory. I used javax.sql.DataSource as the Resource Type and entered com.informix.jdbcx.IfxDataSource as the Datasource Classname . The additional settings properties I entered are pictured below. HTH, Carl