title: SEVERE: Exception sending context initialized event to listener DBListener
body: <p>Hi im not yet familiar in compiling in JAVA and got this error:
  My database is located in another server but i already pointed it on it, by the way im using DCM4CHEE..</p>
  
  <pre><code>Jul 17, 2014 3:39:59 PM org.apache.catalina.core.StandardContext listenerStart
  SEVERE: Exception sending context initialized event to listener instance of class com.xb.util.DBListener
  java.lang.NullPointerException
    at com.xb.util.DBListener.contextInitialized(DBListener.java:27)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>In my DBListener:
  I have this code,</p>
  
  <pre><code>@WebListener
  public class DBListener
    implements ServletContextListener
  {
    public void contextInitialized(ServletContextEvent sce)
    {
      mysql_con db = new mysql_con();
      try
      {
          db.dcmrisenConnect();
          ResultSet rs = db.dcmrisen.getMetaData().getTables(null, null, "partnerslist", null); // this was the pointed error as line 27..
         if (!rs.next())
         {
           String cdbsql = "CREATE TABLE `partnerslist` (`id`  int NOT NULL AUTO_INCREMENT ,`source_sn`  varchar(100) NOT NULL ,`target_sn`  varchar(100) NOT NULL ,`nick_name`  varchar(100) NOT NULL ,`type`  int(3) NOT NULL COMMENT '1 sender 2 receiver' ,PRIMARY KEY (`id`));";
          db.dcmrisenSetQ(cdbsql);
         }
         db.dcmrisenDisconnect();
      }
      catch (SQLException ex)
      {
        ex.printStackTrace();
       }
     }
  
     public void contextDestroyed(ServletContextEvent sce) {}
   }
  </code></pre>
  
  <p>In my mysql_con.class, i have:</p>
  
  <pre><code>public class mysql_con
  {
    public Connection apCenter = null;
    public Connection apLocal = null;
    public Connection dcmrisen = null;
    public Connection pacsio = null;
    public Connection apollo = null;
    private String user = "root";
    private String password = "XXX-test";
    public String serverBasePath = "C:/dcmsyst/dcmPacs01/server-2.17.1/server/default/";
  
    public void dcmrisenConnect()
   {
      try
     {
        Properties localProperties = new Properties();
        localProperties.put("characterEncoding", "UTF-8");
        localProperties.put("useUnicode", "TRUE");
        localProperties.put("user", this.user);
        localProperties.put("password", this.password);
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        this.dcmrisen = DriverManager.getConnection("jdbc:mysql://192.168.1.74/dcmris_en", localProperties);
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
    }
  } 
  </code></pre>
  
  <p>Please help and thanks in advance..</p>