-1
휴면 상태 코드에서 "키워드 'VALUES'근처에 구문이 잘못되었습니다." 내 SQL 문으로 문제를 찾을 수 없습니다.PreparedStatement 값 Java의 오류
/* * SQL 서버에 HistoryData 표 표 구조 * 1) CITY_ID - INT * 2) CITY_NAME - NVARCHAR (50) * 3) 시간 - 날짜 * 4) Received_Time - 날짜 * 5) 습도 - * 6) Rain_info 부동 - 부유 * 7) Snow_info을 - * 8) 온도 부동 - 부유 * 9) Min_Temperature을 - * 10) MAX_TEMPERATURE 부동 - 부유 * 11) 정보 - 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();
'VALUES'앞에 쉼표가 너무 많이 있습니다. – qqilihq
... 대괄호가 없습니다. 전용 SQL 편집기에 SQL 쿼리를 작성하는 것을 고려하십시오. Java 코드 디버깅은 지루합니다. – qqilihq