public TrafficCountRecord saveTrafficCountRecord(TrafficCountRecord trafficCountRecord) throws SQLException { try { Connection connection = getConnection(); Statement s = connection.createStatement(); String sql = "INSERT INTO trafficcount (pid, id, regionid, tagid, countdate, " + "daytype, starttime, endtime, w2, w3, pc, tx, ldv, ldc, hdc, " + "mdb, hdb) " + "VALUES (" + "(SELECT nextval('studyregion_pid_seq'))," + "'" + trafficCountRecord.getId() + "', '" + trafficCountRecord.getRegion() + "', " + "(SELECT id FROM tagdetails WHERE name='" + trafficCountRecord.getTag() + "' AND region = '" + trafficCountRecord.getRegion() + "')" + ", '" + trafficCountRecord.getDate() + "', '" + trafficCountRecord.getDayType() + "', '" + trafficCountRecord.getStartTime() + "', '" + trafficCountRecord.getEndTime() + "', '" + trafficCountRecord.getW2() + "', '" + trafficCountRecord.getW3() + "', '" + trafficCountRecord.getPC() + "', '" + trafficCountRecord.getTX() + "', '" + trafficCountRecord.getLDV() + "', '" + trafficCountRecord.getLDC() + "', '" + trafficCountRecord.getHDC() + "', '" + trafficCountRecord.getMDB() + "', '" + trafficCountRecord.getHDB() + "')"; logger.debug("sql=" + sql); s.executeUpdate(sql); connection.close(); // returns connection to pool } catch (SQLException e) { logger.error(e.getMessage()); throw e; } return trafficCountRecord; }