Niente, purtroppo sempre errore:
codice:run: Ricicla connessione Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at monopoli.Partita.pushButtonInserisciAction(Partita.java:219) at monopoli.Partita.access$000(Partita.java:22) at monopoli.Partita$1.actionPerformed(Partita.java:149) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703) at java.awt.EventQueue.access$000(EventQueue.java:102) at java.awt.EventQueue$3.run(EventQueue.java:662) at java.awt.EventQueue$3.run(EventQueue.java:660) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:676) at java.awt.EventQueue$4.run(EventQueue.java:674) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:673) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139) at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
attualmente ho:
codice:private void pushButtonInserisciAction(ActionEvent event) throws SQLException, ParseException { String data; String giorno; String mese; String anno; int id_partita = 0; int new_partita; try { Statement statement = conn.createStatement(); ResultSet rset = statement.executeQuery( "select MAX(ID_PARTITA) from PARTITA" ); while ( rset.next() ) id_partita = rset.getInt(1); rset.close(); new_partita = id_partita+1; PreparedStatement inserisciPartita = null; String query = "INSERT INTO PARTITA VALUES (?,?)"; giorno = giorniList.getSelectedItem().toString(); mese = (String)mesiList.getSelectedItem().toString(); anno = anniList.getSelectedItem().toString(); data = anno+"-"+mese+"-"+giorno; DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy"); java.util.Date choise = sdf.parse(data.toString()); //System.out.print("Data scelta: " + choise); //System.out.print("Id partita da inserire: " + new_partita); inserisciPartita.setInt(1, new_partita); inserisciPartita.setDate(2, new java.sql.Date(choise.getTime())); inserisciPartita.executeQuery(); JOptionPane.showMessageDialog(this, "Partita inserita correttamente!", "Information", JOptionPane.INFORMATION_MESSAGE); } catch ( SQLException e) { JOptionPane.showMessageDialog(this, "Errore nell'inserimento della partita! Verifica la connessione al db o chiedi all'amministratore!", "Errore", JOptionPane.ERROR_MESSAGE); } }

Rispondi quotando