如何解决oracle.jdbc.driver.OracleDriver registerMBeans

时间:2018-12-11 10:23:29

标签: linux

我在服务器和客户端的VM中都有centos 6.4。我试图将日期变量存储在oracle数据库中。 我从jdatechooser GUI组件获取输入。但是有这个问题。 我将jdatechooser保存在path中; /usr/local/netbeans-8.2/ide/modules/ext

我还在路径/usr/java/jdk1.8.0_20/jre/lib/ext中添加了ojdbc6.jar

  private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt)               

  {                                            


      try
      {
        String JTExtfieldBookIdStr = jTextFieldBookID.getText();
        String JTExtFieldBooknameStr = jTextFieldBookName.getText();
        String JTexTFieldCategoryStr = jTextFieldCategory.getText();
        String JtextAeraDesciptionStr = jTextAreaDescription.getText();

        SimpleDateFormat smpldateformat = new SimpleDateFormat("dd-MM-yyyy");
        String d = smpldateformat.format(jDateChooserRegistryDate.getDate());

        JOptionPane.showMessageDialog(null," smpldatefrmt =  " + d);

        java.util.Date udate =   smpldateformat.parse(d);
        JOptionPane.showMessageDialog(null,"exception in util date : " + udate.toString());
        //java.util.Date udate =   smpldatefrmt.parse(jDateChooserRegistryDateStr);
        long ms = udate.getTime();

        java.sql.Date sqdate = new java.sql.Date(ms);

        String sql = "insert into tablebookmaster values(?, ?, ?, ?, ?);";
        pst = conn.prepareStatement(sql);

        pst.setInt(1, Integer.parseInt(JTExtfieldBookIdStr) );
        //JOptionPane.showMessageDialog(null,"
        pst.setString(2,JTExtFieldBooknameStr);
        pst.setString(3,JTexTFieldCategoryStr);
        pst.setString(4,JtextAeraDesciptionStr);
        pst.setDate(5, sqdate);
        int inserted  = pst.executeUpdate();

        if(inserted != 1)
        {
            JOptionPane.showMessageDialog(null,"insertion problem");       
        }

   }
   catch(Exception e)
   {
       JOptionPane.showMessageDialog(null, "exception in jButtonSaveActionPerformed : " + e);
   }

O / P为:-

having null pointer exception correct date format what i want to insert can not parse date string

0 个答案:

没有答案