public void setTask(String name, String taskJson, String datastoreName) {
		Debug.into(this, "setTask");
		
		if (!identifierTest.matcher(name).matches()) {
			throw new UnsafeRequestException();
		}
		
		ResultSet rs = null;
		PreparedStatement ps = null;
		
		try {
			ps = conn.prepareStatement("SELECT COUNT(*) FROM gate_task WHERE task_name = ? ;");
			ps.setString(1, name);
			rs = ps.executeQuery();
			boolean update;
			update = rs.next() && rs.getInt(1) > 0;	
			rs.close();
			ps.close();
			
			if (update) {
				Debug.println(3, "Updating tesk defination to datastore.");
				ps = conn.prepareStatement("UPDATE gate_task SET task_json = ? , db_name = ? WHERE task_name = ? ;");
				ps.setString(1, taskJson);
				ps.setString(2, datastoreName);
				ps.setString(3, name);
				ps.executeUpdate();
				ps.close();
			} else {
				Debug.println(3, "Saving tesk defination to datastore.");
				ps = conn.prepareStatement("INSERT INTO gate_task ( task_json, db_name, task_name ) VALUES ( ? , ? , ?) ;");
				ps.setString(1, taskJson);
				ps.setString(2, datastoreName);
				ps.setString(3, name);
				ps.executeUpdate();
				ps.close();
			}
			
		} catch (SQLException e) {
			throw new ImplSQLException(e);
		} finally {
			try {
				if (rs != null && !rs.isClosed()) {
					rs.close();
				}
				if (ps != null && !ps.isClosed()) {
					ps.close();
				}
			} catch (SQLException e) {
				throw new ImplSQLException(e);
			}
		}
		Debug.out(this, "setTask");
	}