下面的代码给出了“关键字'VALUES'附近的语法不正确”。我找不到我的 SQL 语句的问题。
/* * SQL Server 中 HistoryData 表的表结构 * 1) City_ID - int * 2)City_Name - nvarchar(50) * 3)Time - datetime * 4)Received_Time - datetime * 5)Humidity - float * 6)Rain_info - float * 7)Snow_info - float * 8)Temperature - float * 9)Min_Temperature - float * 10)Max_Temperature - float * 11)Description - nvarchar(50) */
try
{
String statementString = "INSERT INTO WeatherHistoryX("
+"City_ID,"
+"City_Name,"
+"Time,"
+"Received_Time,"
+"Humdity,"
+"Rain_Info,"
+"Snow_Info,"
+"Temperature,"
+"Min_Temperature,"
+"Max_Temperature,"
+"Description,"
+"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pStatement = connection.prepareStatement(statementString);
//statement = null;
//statement = connection.createStatement();
java.sql.Date sqlDate = new java.sql.Date(weather.getDate());
java.sql.Date currentSqlDate = new java.sql.Date(currentTimestamp.getTime());
pStatement.setInt(1, weather.getCityCode());
pStatement.setString(2, weather.getCity());
pStatement.setDate(3, sqlDate);
pStatement.setDate(4, currentSqlDate);
pStatement.setFloat(5, weather.getHumidity());
pStatement.setFloat(6, weather.getRainInfo());
pStatement.setFloat(7, weather.getSnowInfo());
pStatement.setFloat(8, weather.getTemperature());
pStatement.setFloat(9, weather.getMinTemperature());
pStatement.setFloat(10, weather.getMaxTemperature());
pStatement.setString(11, weather.getDescription());
pStatement.execute();