문제

I write a java program that connect to mysql db with jdbc.It inserts records to mysql. The sql is this:

 INSERT   INTO my_schema.my_table VALUES ('AMERICAN', '97', '1995-08-28 00:00:00', '10', '1995-08-28 00:00:00', '10', 'United States Dollar', 'USD', '$', '2', 'Y', 'Y', '1995-08-28 00:00:00', '_6064530F8DBAB938E040007F010015E3' );

But it gives this error:

e = (java.sql.BatchUpdateException) 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 '('AMERICAN', '40', '1995-08-28 00:00:00', '10', '1995-08-28 00:00:00', '10', 'Ja' at line 1

But the weird thing is : I insert it manually without error.

thanks in advance,

도움이 되었습니까?

해결책

It is weird but it works:

I just remove the last character semicolon , and it works:

I mean I change this:

INSERT   INTO my_schema.my_table VALUES ('AMERICAN', '97', '1995-08-28 00:00:00', '10', '1995-08-28 00:00:00', '10', 'United States Dollar', 'USD', '$', '2', 'Y', 'Y', '1995-08-28 00:00:00', '_6064530F8DBAB938E040007F010015E3' );

to this:

INSERT   INTO my_schema.my_table VALUES ('AMERICAN', '97', '1995-08-28 00:00:00', '10', '1995-08-28 00:00:00', '10', 'United States Dollar', 'USD', '$', '2', 'Y', 'Y', '1995-08-28 00:00:00', '_6064530F8DBAB938E040007F010015E3' )
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top