java - Inserting date into database without use of prepared statement -
I am struggling to include this date in moviesTbl
I hope to do this without expecting to prepare. I got an error when I tried it below:
Exception in thread "main" net.ucanaccess.jdbc.UcanaccessSQLException: User's privilege or object was not found: Release
Here is the code:
string date = "2012-12-28"; Java.sql.Date release = java.sql.Date.valueOf (date); Enter Qtd.update ("MovieTTB (Title, ReleaseDate, Style) values ('Harry Potter', released, 'Drama')");
How can I insert a date without a prepared statement?
If you have variables recharges
inside quotation marks, then incorrect methods of SQL I'm saying something on the lines of "I can not get the variable issued". You have to put your variable in Java so that the value can be kept in SQL otherwise SQL Server is looking for a variable released, but it's definitely not there, it's in your Java.
string date = "2012-12-28"; Enter in the Qtd.update ("MovieTTB" (Title, ReleaseDate, Style) values ('Harry Potter', '+' 'Date' '', 'Drama'));
As @ User 2067753 said that there are different formats for getting and setting up data time formats in different databases, assuming that you are using MS SQL Server, you can do something like < / P>
java.util.Date date = New SimpleDateform ("yyyy-MM-dd"). Pars ("2012-12 -28"); Java.text.SimpleDateFormat msSqlDateFormat = new java.text .SimpleDateF Ormat ("yyyy-MM-dd HH: mm: ss"); Qtd.update ("Enter the movieTTB (title, release date, style) values ('Harry Potter', '' + MSSQLad Format Format (date) + '' ,' the drama ') ");
Comments
Post a Comment