Salve,
come faccio ad eseguire da Java un file .sql ,creato con MySql Administrator, per l'aggiornamento del db?
ho provato questo codice :
ma ottengo il seguente errore :codice:try { Statement s = db.createStatement(); BufferedReader in = new BufferedReader(new FileReader("file.sql")); String str; StringBuffer sb = new StringBuffer(); while ((str = in.readLine()) != null) { sb.append(str + "\n "); } in.close(); s.addBatch(sb.toString()); s.executeBatch(); s.close(); } catch (Exception e) { System.out.println("errore in aggiornamento"); }
lo stesso file viene correttamente eseguito sia da mysql admin che da mysql query browsercodice:java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101' at line 7



Rispondi quotando