SEVERE:将上下文初始化事件发送到侦听器DBListener的异常

时间:2014-07-17 08:00:28

标签: java class event-listener dcm4che

您好我还不熟悉JAVA编译并得到此错误: 我的数据库位于另一台服务器上,但我已经指出了它,顺便说一下我使用的是DCM4CHEE ..

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)

在我的DBListener中: 我有这个代码,

@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) {}
 }

在我的mysql_con.class中,我有:

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();
    }
  }
} 

请提前帮助并表示感谢..

0 个答案:

没有答案