Problem:
mir wird eine Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
geworfen.
Obwohl alles richtig ist. Also für mich
private static void insertDocumentIntoDatabase(File file,Connection con) throws Exception
{
// Schreibe in Datenbank
System.out.println("Schreibe in Datenbank");
// String query = "INSERT INTO `p_fehleranalyse`.`fehlercomment` (`id`,`fehler`,`aggregat`,`abbindung`,`nacharbeit`,`bemerkung`) VALUES ('"+id+"', '"+fehler+"', '"+aggregat+"', '"+abbindung+"', '"+nacharbeit+"', '"+bemerkung+"')";
PreparedStatement preparedStatement = con.prepareStatement("INSERT INTO `fehleranalyse`.`file_data` (`data`,`bez`) VALUES ('"+file+"', 'Datei')");
preparedStatement.setBinaryStream(1,new FileInputStream(file),(int) file.length());
preparedStatement.execute();
preparedStatement.close();
}
In der Methode geht er rein aber dort wird mir eine exception geworfen.
Aufruf:
File file = new File("C:/Dokumente und Einstellungen/datum.txt");
insertDocumentIntoDatabase(file,conn);
Wieß jemand wiesooo ??????
mir wird eine Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
geworfen.
Obwohl alles richtig ist. Also für mich
private static void insertDocumentIntoDatabase(File file,Connection con) throws Exception
{
// Schreibe in Datenbank
System.out.println("Schreibe in Datenbank");
// String query = "INSERT INTO `p_fehleranalyse`.`fehlercomment` (`id`,`fehler`,`aggregat`,`abbindung`,`nacharbeit`,`bemerkung`) VALUES ('"+id+"', '"+fehler+"', '"+aggregat+"', '"+abbindung+"', '"+nacharbeit+"', '"+bemerkung+"')";
PreparedStatement preparedStatement = con.prepareStatement("INSERT INTO `fehleranalyse`.`file_data` (`data`,`bez`) VALUES ('"+file+"', 'Datei')");
preparedStatement.setBinaryStream(1,new FileInputStream(file),(int) file.length());
preparedStatement.execute();
preparedStatement.close();
}
In der Methode geht er rein aber dort wird mir eine exception geworfen.
Aufruf:
File file = new File("C:/Dokumente und Einstellungen/datum.txt");
insertDocumentIntoDatabase(file,conn);
Wieß jemand wiesooo ??????