Hallo
ich bräuchte Hilfe weil ich absolut keine Lösung für mein Problem finde. Ich bin dabei Dateien in eine Datenbank zu schreiben und habe dafür ein kleines Programm geschrieben. Hat auch zunächst gut funktioniert aber dann nach einigen Aufrufen kam folgende Fehlermeldung:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 '' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2713)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2663)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1599)
at ForecastList.writeForecast(ForecastList.java:109)
at ExcelReader.readForecast(ExcelReader.java:204)
at ExcelReader.main(ExcelReader.java:65)
Mein Problem hierbei ist, dass das Statement einige 100 mal geklappt hat und dann das letzte richtige folgendes war:
Insert into table1 (Contract_CONTRACT, Value1, Value2, Value3, Value4, Value5, Value6, Value7, Value8, Value9, Value10,Value11, Value12, Year, Month) Values (Contract, 0, 0, 0, 2948.45, 673.89, 630.84, 0, 0, 0, 0, 0, 0, 2012, 10 )
und bei diesem kam die obige Fehlermeldung:
Insert into table1 (Contract_CONTRACT, Value1, Value2, Value3, Value4, Value5, Value6, Value7, Value8, Value9, Value10,Value11, Value12, Year, Month) Values (Contract2, 0, 0, 0, 0, 0, 0, 6519.00, 1787.50, 1790.00, 1790, 1790, 1790, 2012, 10 )
Die Tabelle wurde durch:
CREATE TABLE IF NOT EXISTS `mydb`.`table1` (
`idForecast` INT NOT NULL AUTO_INCREMENT ,
`Year` VARCHAR(5) NULL ,
`Month` VARCHAR(5) NULL ,
`Value1` FLOAT NULL ,
`Value2` FLOAT NULL ,
`Value3` FLOAT NULL ,
`Value4` FLOAT NULL ,
`Value5` FLOAT NULL ,
`Value6` FLOAT NULL ,
`Value7` FLOAT NULL ,
`Value9` FLOAT NULL ,
`Value10` FLOAT NULL ,
`Value11` FLOAT NULL ,
`Value12` FLOAT NULL ,
`Contract_CONTRACT` VARCHAR(15) NOT NULL ,
`Value8` DOUBLE NULL ,
PRIMARY KEY (`idForecast`) ,
INDEX `fk_Forecast_Contract1` (`Contract_CONTRACT` ASC) ,
CONSTRAINT `fk_Forecast_Contract1`
FOREIGN KEY (`Contract_CONTRACT` )
REFERENCES `mydb`.`Contract` (`CONTRACT` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
erstellt.
Wenn mir jemand auf die Sprünge helfen könnte wäre ich sehr dankbar.
Liebe Grüße und danke schonmal.
Florian
ich bräuchte Hilfe weil ich absolut keine Lösung für mein Problem finde. Ich bin dabei Dateien in eine Datenbank zu schreiben und habe dafür ein kleines Programm geschrieben. Hat auch zunächst gut funktioniert aber dann nach einigen Aufrufen kam folgende Fehlermeldung:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 '' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2713)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2663)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1599)
at ForecastList.writeForecast(ForecastList.java:109)
at ExcelReader.readForecast(ExcelReader.java:204)
at ExcelReader.main(ExcelReader.java:65)
Mein Problem hierbei ist, dass das Statement einige 100 mal geklappt hat und dann das letzte richtige folgendes war:
Insert into table1 (Contract_CONTRACT, Value1, Value2, Value3, Value4, Value5, Value6, Value7, Value8, Value9, Value10,Value11, Value12, Year, Month) Values (Contract, 0, 0, 0, 2948.45, 673.89, 630.84, 0, 0, 0, 0, 0, 0, 2012, 10 )
und bei diesem kam die obige Fehlermeldung:
Insert into table1 (Contract_CONTRACT, Value1, Value2, Value3, Value4, Value5, Value6, Value7, Value8, Value9, Value10,Value11, Value12, Year, Month) Values (Contract2, 0, 0, 0, 0, 0, 0, 6519.00, 1787.50, 1790.00, 1790, 1790, 1790, 2012, 10 )
Die Tabelle wurde durch:
CREATE TABLE IF NOT EXISTS `mydb`.`table1` (
`idForecast` INT NOT NULL AUTO_INCREMENT ,
`Year` VARCHAR(5) NULL ,
`Month` VARCHAR(5) NULL ,
`Value1` FLOAT NULL ,
`Value2` FLOAT NULL ,
`Value3` FLOAT NULL ,
`Value4` FLOAT NULL ,
`Value5` FLOAT NULL ,
`Value6` FLOAT NULL ,
`Value7` FLOAT NULL ,
`Value9` FLOAT NULL ,
`Value10` FLOAT NULL ,
`Value11` FLOAT NULL ,
`Value12` FLOAT NULL ,
`Contract_CONTRACT` VARCHAR(15) NOT NULL ,
`Value8` DOUBLE NULL ,
PRIMARY KEY (`idForecast`) ,
INDEX `fk_Forecast_Contract1` (`Contract_CONTRACT` ASC) ,
CONSTRAINT `fk_Forecast_Contract1`
FOREIGN KEY (`Contract_CONTRACT` )
REFERENCES `mydb`.`Contract` (`CONTRACT` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
erstellt.
Wenn mir jemand auf die Sprünge helfen könnte wäre ich sehr dankbar.
Liebe Grüße und danke schonmal.
Florian
Zuletzt bearbeitet: