ho risolto ma riesco ad inserire solo la prima ricerca (in tutto sono 13 risultati)
ho fatto in questo modo....
nella chiamata ho messo:codice:private static void inserisci(String fileText, String fileName) throws IOException { String connStr = "jdbc:mysql://localhost:1980/" + "test?user=root&password=nicola"; String statement2 = "INSERT INTO guestbook (message, messageDate) " + "VALUES (?, ?)"; Connection conn = null; String PreparedStatement=null; try { FileWriter fileWriter = new FileWriter(fileName); fileWriter.write(fileText); fileWriter.close(); Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(connStr); PreparedStatement stmt2 = conn.prepareStatement(statement2); stmt2.setString(1, fileText); stmt2.setObject(2, new java.util.Date()); stmt2.executeUpdate(); stmt2.close(); if (stmt2.executeUpdate() <= 0) { System.out.println("Esecuzione UPDATE non riuscita!"); } stmt2.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); }catch (SQLException e){ e.printStackTrace();} // handle any errors }
poi mi dice...codice:inserisci(stringBuffer.toString(), fileWrite);
java.lang.NullPointerException
come faccio ad inserire anche le altre?

Rispondi quotando