I am trying to access the Jetspeed database. There is a jetspeed.xml file in 
{tomcat_dir}/conf/Catalina/localhost/. I know Jetspeed can access the database 
but I can't seem to get access to it. Does anyone know how Jetspeed is setting 
up the database connection? When I try the following code, I get a naming 
exception. If anyone knows why that code does not get the work please let me 
know ASAP. Thanks!
 
==== BEGIN MY getConnection FUNCTION ====
public static Connection getConnection(RenderResponse response)
   throws IOException {
  // TODO Auto-generated method stub
  try {
   Context initCtx = new InitialContext();
   Context envCtx = (Context) initCtx.lookup("java:/comp/env");
   if (envCtx == null) {
    throw new Exception("Boom - No Environment Context");
   }
   // envCtx.1
   DataSource ds = (DataSource) envCtx.lookup("jdbc/jetspeed");
   if (ds != null) {
    return ds.getConnection();
   } else {
    return null;
   }
  } catch (NamingException ex) {
   ex.printStackTrace(response.getWriter());
  } catch (Exception ex) {
   ex.printStackTrace(response.getWriter());
  }
 
  return null;
 }
 
==== END MY getConnection FUNCTION ====

Reply via email to