All pastes #742530 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-10-19 16:27 UTC
rendered paste body
		Connection conn = connect();


		String tableName = "tmp_prodxy_" + System.currentTimeMillis();
		String sqlCreate = "create temporary table " + tableName + " (id bigint not null) ";
		String sqlAddIndex = "create index tmp_idx_" + tableName + " on " + tableName + "(id)";
		String sqlAddData = "insert into " + tableName + " values " + insertClause;
		String sqlQuery = "select distinct tfm.blogPostId, tfm.publishedDate " +
				"from TopicFilterMatch tfm join " + tableName + " tmp on tfm.blogPostId = tmp.id " +
				" where tfm.topicFilterId in (" + topicFilterList+ ") and tfm.postStatusId<1";
		String sqlDrop = "drop table " + tableName;
		
		System.out.println("PRODXY:" + tableName + "\n" + sqlCreate 
				 + "\n" + sqlAddIndex + "\n" + sqlAddData + "\n" + sqlQuery+ "\n" + sqlDrop);

		
		Statement stmt = null;
		ArrayList<Long> results = new ArrayList();
		ResultSet rs = null;
		int result = 0;
		try {
			
			stmt = conn.createStatement();
			stmt.execute(sqlCreate);
			stmt.close();
			stmt = conn.createStatement();
			stmt.execute(sqlAddIndex);
			stmt.close();
			
			stmt = conn.createStatement();
			rs = stmt.executeQuery(sqlQuery);

			
			while (rs.next()) {
				results.add(rs.getTimestamp("publishedDate").getTime());	
			}
			
			stmt.close();
			stmt = conn.createStatement();
			stmt.execute(sqlDrop);

		} catch (Exception e) {
			
			e.printStackTrace();
			
		}