public static void inserir(Investimento investimento, Obra obra) throws SQLException { System.out.println("chegou no ins invest"); System.out.println(investimento.toString() + "" + obra.toString()); // Criar investimento try { con = (Connection) BdConecta.getConnection(); } catch (SQLException e) { System.out.println(e.getMessage()); } java.sql.PreparedStatement stmt = InvestimentoDAO.con.prepareStatement( "insert into investimento (idinvestimento," + " valor_invest, data_invest, descricao_invest,obra_id)" + " values(?,?,?,?,?)"); stmt.setInt(1, investimento.getIdInvestimento()); stmt.setDouble(2, investimento.getValor()); java.sql.Date date = new java.sql.Date(Calendar.getInstance().getTime().getTime()); stmt.setDate(3, (java.sql.Date) date); stmt.setString(4, investimento.getDescricao()); stmt.setInt(5, obra.getId_obra()); try { stmt.execute(); System.out.println("invest criado"); stmt.close(); con.close(); JOptionPane.showMessageDialog(null, "gravado com successo"); } catch (Exception e) { e.getMessage(); } }