Code example for Connection

Methods: prepareStatement

0
	private SimpleDateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy");
	 
	public void doCronProcess(String servername, Ini configIni, Section processSettings, Connection vufindConn, Connection econtentConn, CronLogEntry cronEntry, Logger logger) {
		this.logger = logger;
		processLog = new CronProcessLogEntry(cronEntry.getLogEntryId(), "Import blueink reviews");
		processLog.saveToDatabase(vufindConn, logger);
		 
		vufindUrl = Util.cleanIniValue(configIni.get("Site", "url"));
		 
		//Setup the Prepared Statements we will need 
		try { 
			checkForExistingReview = vufindConn.prepareStatement("SELECT editorialReviewId, review, pubDate FROM editorial_reviews WHERE recordId = ? AND source = 'BlueInk Reviews'");
			insertNewReview = vufindConn.prepareStatement("INSERT INTO editorial_reviews (recordId, title, pubDate, review, source) VALUES (?, ?, ?, ?, ?)");
			updateExistingReview = vufindConn.prepareStatement("UPDATE editorial_reviews SET title = ?, pubDate = ?, review = ? WHERE editorialReviewId = ?");
		} catch (SQLException e) {
			logger.error("Error creating prepared statements to update blueink reviews", e);
			processLog.addNote("Error creating prepared statements to update blueink reviews " + e.toString());
			processLog.incErrors();
		} 
		 
		 
		//Load information from the reviews feed 
		importReviewsFromFeed("http://www.blueinkreview.com/files/reviews.xml"); 
		 
		//TODO: Load information from the archive feed? 
		//Right now the reviews provided in each feed are identical so there is no need to import both.  
		//importReviewsFromFeed("http://www.blueinkreview.com/files/reviews.xml"); 
		 
		processLog.setFinished();
		processLog.saveToDatabase(vufindConn, logger);
	} 
 
	private void importReviewsFromFeed(String blueinkFeed) {
		//Get a list of all reviews from the blueink feed 
		processLog.addNote("Loading reviews from " + blueinkFeed);