0

こんにちは、私はまだ 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();
    }
  }
} 

助けてください、事前に感謝します..

4

0 に答える 0