IMHO, you will need to use the following codes once you are using connection retrieved through JNDI datasource. (found here:) I have also provided details on how to retrieve the JNDI datasource below.
■3113: "end-of-file on communication channel"
■3114: "not connected to ORACLE"
■1033: "ORACLE initialization or shutdown in progress"
■1034: "ORACLE not available"
■1089: "immediate shutdown in progress - no operations are permitted"
■1090: "shutdown in progress - connection is not permitted"
■17002: "I/O exception"
=========================== Code to retrieve the connection from datasource
InitialContext ic = new InitialContext();
com.sun.appserv.DataSource ds = (com.sun.appserv.DataSOurce) ic.lookup("jdbc/PointBase");
Connection con = ds.getConnection();
Connection drivercon = ds.getConnection(con);
Glassfish datasource javadoc is here
If you dont want to deploy the application, but use the datasource of a remote glassfish server, get the initialcontext
as below
Properties props=new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
props.put(Context.PROVIDER_URL,"iiop://URL_OF_APP_SERVER:PORT");
Context ctx=new InitialContext(props);
DataSource datasource = (DataSource)ctx.lookup("jndi/mydatasource");