如何从数据库获取序列的下一个值并使用oracle 10g在netbeans中的JOptionPane中显示它?

时间:2016-04-06 17:26:21

标签: java oracle netbeans

private void button_saveandsubmitnowActionPerformed(java.awt.event.ActionEvent evt) {                                                        

           con = JavaConnectDB.ConnectDB();
    try{
       String sql="select MISSINGPERSON_SEQUENCE.nextval from DUAL";

       pst = (OraclePreparedStatement) con.prepareStatement(sql);     
       rs = (OracleResultSet) pst.executeQuery();

     JOptionPane.showMessageDialog(null, "\nCase number: "+rs.getString(1));

      rs = (OracleResultSet) pst.executeQuery();


        if(rs.next()){
           JOptionPane.showMessageDialog(null, "the details have been added successfully!!!");
           con.close();
           this.dispose();
        }
        else{
            JOptionPane.showMessageDialog(null, "enter all fields appropriately first!!!");
        }
        con.close();
    }catch(Exception e){
        JOptionPane.showMessageDialog(null, "An error occured. try again later !!!");
    }
}

image

0 个答案:

没有答案